diff src/libpam/conversation.rs @ 93:efc2b56c8928

Remove undefined behavior per MIRI. This replaces a bunch of raw pointers with NonNull and removes all the undefined behavior that we can find with MIRI. We also remove the `SecureString` dependency (since it doesn't work with MIRI, and because it's not really necessary).
author Paul Fisher <paul@pfish.zone>
date Mon, 23 Jun 2025 13:02:58 -0400
parents dd3e9c4bcde3
children f3e260f9ddcb
line wrap: on
line diff
--- a/src/libpam/conversation.rs	Sun Jun 22 19:29:32 2025 -0400
+++ b/src/libpam/conversation.rs	Mon Jun 23 13:02:58 2025 -0400
@@ -2,7 +2,7 @@
 use crate::conv::{Conversation, ErrorMsg, InfoMsg, MaskedQAndA, Message, QAndA};
 use crate::libpam::answer::BinaryAnswer;
 use crate::libpam::answer::{Answer, Answers, TextAnswer};
-use crate::libpam::memory::Immovable;
+use crate::libpam::memory::{CBinaryData, Immovable};
 use crate::libpam::pam_ffi::AppData;
 pub use crate::libpam::pam_ffi::LibPamConversation;
 use crate::libpam::question::QuestionsTrait;
@@ -139,7 +139,10 @@
         Message::RadioPrompt(qa) => fill_text!(qa, resp),
         Message::BinaryPrompt(qa) => {
             let bin_resp = unsafe { BinaryAnswer::upcast(resp) };
-            qa.set_answer(Ok(bin_resp.data().into()));
+            qa.set_answer(Ok(bin_resp
+                .data()
+                .map(|d| unsafe { CBinaryData::as_binary_data(d) })
+                .unwrap_or_default()));
             bin_resp.zero_contents()
         }
     }