Mercurial > crates > nonstick
changeset 29:c16564971c05
conv: fix segfault when decoding response of PAM_TEXT_INFO et al.
author | holycleugh <holycleugh> |
---|---|
date | Sun, 30 Dec 2018 03:40:41 -0500 |
parents | 81a9f0479e50 |
children | 539d81e3bdc2 |
files | pam/src/conv.rs |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pam/src/conv.rs Sun Dec 30 03:40:04 2018 -0500 +++ b/pam/src/conv.rs Sun Dec 30 03:40:41 2018 -0500 @@ -64,10 +64,12 @@ let ret = (self.conv)(1, &&msg, &mut resp_ptr, self.appdata_ptr); if PamResultCode::PAM_SUCCESS == ret { - if resp_ptr.is_null() { + // PamResponse.resp is null for styles that don't return user input like PAM_TEXT_INFO + let response = unsafe { (*resp_ptr).resp }; + if response.is_null() { Ok(None) } else { - let bytes = unsafe { CStr::from_ptr((*resp_ptr).resp).to_bytes() }; + let bytes = unsafe { CStr::from_ptr(response).to_bytes() }; Ok(String::from_utf8(bytes.to_vec()).ok()) } } else {