Mercurial > crates > nonstick
diff src/libpam/conversation.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 | efbc235f01d3 |
children | a508a69c068a |
line wrap: on
line diff
--- a/src/libpam/conversation.rs Thu Jul 03 20:55:40 2025 -0400 +++ b/src/libpam/conversation.rs Thu Jul 03 23:57:49 2025 -0400 @@ -2,12 +2,11 @@ use crate::conv::{Conversation, ErrorMsg, Exchange, InfoMsg, MaskedQAndA, QAndA}; use crate::libpam::answer::BinaryAnswer; use crate::libpam::answer::{Answer, Answers, TextAnswer}; -use crate::libpam::memory::CBinaryData; use crate::libpam::question::Question; use crate::ErrorCode; use crate::Result; +use libpam_sys::AppData; use libpam_sys_helpers::memory::PtrPtrVec; -use libpam_sys::AppData; use std::ffi::c_int; use std::iter; use std::marker::PhantomData; @@ -153,8 +152,8 @@ Exchange::BinaryPrompt(qa) => { let bin_resp = unsafe { BinaryAnswer::upcast(resp) }; qa.set_answer(Ok(bin_resp - .data() - .map(|d| unsafe { CBinaryData::as_binary_data(d) }) + .contents() + .map(|d| d.into()) .unwrap_or_default())); bin_resp.zero_contents() }