File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -1980,14 +1980,19 @@ pub mod module {
1980
1980
Ok ( vm. ctx . new_int ( written as u64 ) . into ( ) )
1981
1981
}
1982
1982
1983
+ #[ cfg( target_os = "linux" ) ]
1984
+ unsafe fn sys_getrandom ( buf : * mut libc:: c_void , buflen : usize , flags : u32 ) -> isize {
1985
+ libc:: syscall ( libc:: SYS_getrandom , buf, buflen, flags as usize ) as _
1986
+ }
1987
+
1983
1988
#[ cfg( target_os = "linux" ) ]
1984
1989
#[ pyfunction]
1985
1990
fn getrandom ( size : isize , flags : OptionalArg < u32 > , vm : & VirtualMachine ) -> PyResult < Vec < u8 > > {
1986
1991
let size = usize:: try_from ( size)
1987
1992
. map_err ( |_| vm. new_os_error ( format ! ( "Invalid argument for size: {}" , size) ) ) ?;
1988
1993
let mut buf = Vec :: with_capacity ( size) ;
1989
1994
unsafe {
1990
- let len = libc :: getrandom (
1995
+ let len = sys_getrandom (
1991
1996
buf. as_mut_ptr ( ) as * mut libc:: c_void ,
1992
1997
size,
1993
1998
flags. unwrap_or ( 0 ) ,
You can’t perform that action at this time.
0 commit comments