From d3ef800bb39a2b2b5a5b700dac5f2b444cfaf5e5 Mon Sep 17 00:00:00 2001 From: Vimal Date: Tue, 5 Apr 2022 15:57:04 -0700 Subject: [PATCH] Truncated value is OK --- src/unix/funcs.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/unix/funcs.rs b/src/unix/funcs.rs index 034e606..42fd098 100644 --- a/src/unix/funcs.rs +++ b/src/unix/funcs.rs @@ -274,12 +274,9 @@ pub fn value_oid(oid: &mut Vec) -> Result { // Confirm that we did not read out of bounds assert!(new_val_len <= val_len); - // Confirm that we got the bytes we requested + // https://github.com/golang/sys/blob/43e60d72a8e2bd92ee98319ba9a384a0e9837c08/unix/syscall_bsd.go#L545-L548 if new_val_len < val_len { - return Err(SysctlError::ShortRead { - read: new_val_len, - reported: val_len, - }); + val.truncate(new_val_len); } // Wrap in Enum and return