Use a const for getentropy(2)'s syscall number
Reported by Sebastien Marie.
This commit is contained in:
parent
a51b70b816
commit
3ee3a784bf
1 changed files with 5 additions and 1 deletions
|
@ -208,6 +208,8 @@ mod imp {
|
|||
fn syscall(number: c_long, ...) -> c_long;
|
||||
}
|
||||
|
||||
const NR_GETENTROPY: libc::c_long = 7;
|
||||
|
||||
impl OsRng {
|
||||
/// Create a new `OsRng`.
|
||||
pub fn new() -> io::Result<OsRng> {
|
||||
|
@ -231,7 +233,9 @@ mod imp {
|
|||
|
||||
// getentropy(2) permits a maximum buffer size of 256 bytes
|
||||
for s in v.chunks_mut(256) {
|
||||
unsafe { ret = syscall(7, s.as_mut_ptr(), s.len()); }
|
||||
unsafe {
|
||||
ret = syscall(NR_GETENTROPY, s.as_mut_ptr(), s.len());
|
||||
}
|
||||
if ret == -1 {
|
||||
panic!("unexpected getentropy error: {}", errno());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue