Mercurial > crates > nonstick
comparison src/libpam/environ.rs @ 139:33b9622ed6d2
Remove redundant memory management in nonstick::libpam; fix UB.
- Uses the libpam-sys-helpers BinaryPayload / OwnedBinaryPayload structs
to handle memory management and parsing for Linux-PAM binary messages.
- Gets rid of the (technically) undefined behavior in PtrPtrVec
due to pointer provenance.
- Don't check for malloc failing. It won't, even if it does.
- Formatting/cleanups/etc.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 03 Jul 2025 23:57:49 -0400 |
parents | 80c07e5ab22f |
children | a508a69c068a |
comparison
equal
deleted
inserted
replaced
138:999bf07efbcb | 139:33b9622ed6d2 |
---|---|
209 test("SOME", "SOME", ""); | 209 test("SOME", "SOME", ""); |
210 test("", "", ""); | 210 test("", "", ""); |
211 } | 211 } |
212 | 212 |
213 fn env_list(strings: &[&'static str]) -> EnvList<'static> { | 213 fn env_list(strings: &[&'static str]) -> EnvList<'static> { |
214 let ptrs: NonNull<Option<CHeapString>> = memory::calloc(strings.len() + 1).unwrap(); | 214 let ptrs: NonNull<Option<CHeapString>> = memory::calloc(strings.len() + 1); |
215 unsafe { | 215 unsafe { |
216 for (idx, &text) in strings.iter().enumerate() { | 216 for (idx, &text) in strings.iter().enumerate() { |
217 ptr::write( | 217 ptr::write( |
218 ptrs.as_ptr().add(idx), | 218 ptrs.as_ptr().add(idx), |
219 Some(CHeapString::new(text).unwrap()), | 219 Some(CHeapString::new(text).unwrap()), |