Skip to content

Commit e45337e

Browse files
authored
crypto.rand: do not go beyond the buffer boundaries (#26764)
1 parent 92ec9f3 commit e45337e

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

vlib/crypto/rand/rand_linux.c.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn read(bytes_needed int) ![]u8 {
2525
return &ReadError{}
2626
}
2727
bytes_read += rbytes
28+
remaining_bytes -= rbytes
2829
}
2930
return unsafe { buffer.vbytes(bytes_needed) }
3031
}

vlib/crypto/rand/rand_solaris.c.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub fn read(bytes_needed int) ![]u8 {
2828
return &ReadError{}
2929
}
3030
bytes_read += rbytes
31+
remaining_bytes -= rbytes
3132
}
3233
return unsafe { buffer.vbytes(bytes_needed) }
3334
}

0 commit comments

Comments
 (0)