fix: uncomment code to make lib functional until we refactor

This commit is contained in:
Anton Livaja 2024-09-23 14:00:23 -04:00
parent 76354f144a
commit 9280fb8d6d
Signed by: anton
GPG Key ID: 44A86CFF1FDF0E85
1 changed files with 13 additions and 5 deletions

View File

@ -13,15 +13,26 @@ fn fakerand_value() -> Option<i32> {
*FAKERAND.get_or_init(|| env::var("FAKERAND").ok().and_then(|v| v.parse().ok()))
}
/*
#[no_mangle]
pub extern "C" fn rand() -> c_int {
println!("rand() called");
if let Some(fakerand) = fakerand_value() {
println!("rand() value {}", fakerand);
return fakerand;
}
// match fakerand_value() {
// Some(n) => return n,
// None => {
// eprint!("fakerand loaded but unable to generate fake rand");
// unsafe {
// let errno = libc::__errno_location();
// *errno = libc::EINVAL;
// }
// return -1;
// }
// };
unsafe {
let symbol = dlsym(RTLD_NEXT, "rand\0".as_ptr() as *const _);
@ -34,7 +45,6 @@ pub extern "C" fn rand() -> c_int {
}
}
}
*/
#[inline(always)]
unsafe fn copy_slice_to_ptr(slice: &[u8], buf: *mut c_void, buf_size: usize) {
@ -129,7 +139,6 @@ pub extern "C" fn read(fd: c_int, buf: *mut c_void, count: usize) -> ssize_t {
original_read(fd, buf, count)
}
/*
/// # Safety
///
/// Checked by caller. This function may result in undefined behavior if buflen is longer than the
@ -173,7 +182,6 @@ pub extern "C" fn RAND_bytes(buf: *mut c_uchar, num: c_int) -> c_int {
}
}
}
*/
#[cfg(test)]
mod tests {