Skip to content

Commit 394f622

Browse files
authored
Merge pull request #207 from saethlin/master
Fix UB: strlen called without a null terminator
2 parents edca012 + 5e1121b commit 394f622

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,14 @@ mod test {
451451
#[test]
452452
fn test_c_confirm_callback() {
453453
let ret = confirm_callback(
454-
"".as_ptr() as *const std::os::raw::c_char,
454+
"\0".as_ptr() as *const std::os::raw::c_char,
455455
&mut 1u32 as *mut _ as *mut std::os::raw::c_void,
456456
);
457457
assert_eq!(1, ret);
458458
assert_eq!(Bool::Yes, Bool::from(ret));
459459

460460
let ret = confirm_callback(
461-
"".as_ptr() as *const std::os::raw::c_char,
461+
"\0".as_ptr() as *const std::os::raw::c_char,
462462
&mut 0u32 as *mut _ as *mut std::os::raw::c_void,
463463
);
464464
assert_eq!(0, ret);
@@ -469,13 +469,13 @@ mod test {
469469
fn test_c_logging_callback() {
470470
logging_callback(
471471
libcryptsetup_rs_sys::CRYPT_LOG_ERROR as i32,
472-
"".as_ptr() as *const std::os::raw::c_char,
472+
"\0".as_ptr() as *const std::os::raw::c_char,
473473
&mut 1u32 as *mut _ as *mut std::os::raw::c_void,
474474
);
475475

476476
logging_callback(
477477
libcryptsetup_rs_sys::CRYPT_LOG_DEBUG as i32,
478-
"".as_ptr() as *const std::os::raw::c_char,
478+
"\0".as_ptr() as *const std::os::raw::c_char,
479479
&mut 0u32 as *mut _ as *mut std::os::raw::c_void,
480480
);
481481
}

0 commit comments

Comments
 (0)