Skip to content

Commit

Permalink
Truncated value is OK
Browse files Browse the repository at this point in the history
  • Loading branch information
jvimal-eg committed Apr 5, 2022
1 parent 3428320 commit d3ef800
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/unix/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,9 @@ pub fn value_oid(oid: &mut Vec<i32>) -> Result<CtlValue, SysctlError> {

// 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
Expand Down

0 comments on commit d3ef800

Please sign in to comment.