Skip to content

Commit 699d17b

Browse files
committed
fix(pageant): include NUL terminator in WM_COPYDATA payload
Pageant expects the mapping name sent through WM_COPYDATA to be an ASCIZ string and validates the final byte of cbData. The previous code used CString::as_bytes(), so cbData omitted the terminating NUL even though the pointer referenced a NUL-terminated buffer. Pageant therefore rejected the request and the client observed an early EOF. Use as_bytes_with_nul() for both the payload length and pointer.
1 parent 149f8eb commit 699d17b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pageant/src/wmmessage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ pub fn query_pageant_direct(cookie: String, msg: &[u8]) -> Result<Vec<u8>, Error
255255
let char_buffer = CString::new(map_name.as_bytes()).map_err(|_| Error::InvalidCookie)?;
256256
let cds = COPYDATASTRUCT {
257257
dwData: _AGENT_COPYDATA_ID as usize,
258-
cbData: char_buffer.as_bytes().len() as u32,
259-
lpData: char_buffer.as_bytes().as_ptr() as *mut _,
258+
cbData: char_buffer.as_bytes_with_nul().len() as u32,
259+
lpData: char_buffer.as_bytes_with_nul().as_ptr() as *mut _,
260260
};
261261

262262
let response = unsafe {

0 commit comments

Comments
 (0)