File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -409,11 +409,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
409
409
) ?;
410
410
let timeout = this. read_scalar ( timeout) ?. to_i32 ( ) ?;
411
411
412
- if epfd <= 0 {
412
+ if epfd <= 0 || maxevents <= 0 {
413
413
let einval = this. eval_libc ( "EINVAL" ) ;
414
414
this. set_last_error ( einval) ?;
415
415
return Ok ( Scalar :: from_i32 ( -1 ) ) ;
416
416
}
417
+
417
418
// FIXME: Implement blocking support
418
419
if timeout != 0 {
419
420
throw_unsup_format ! ( "epoll_wait: timeout value can only be 0" ) ;
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ fn main() {
19
19
test_epoll_ctl_del ( ) ;
20
20
test_pointer ( ) ;
21
21
test_two_same_fd_in_same_epoll_instance ( ) ;
22
+ test_epoll_wait_less_maxevent_zero ( ) ;
22
23
}
23
24
24
25
// Using `as` cast since `EPOLLET` wraps around
@@ -528,3 +529,17 @@ fn test_no_notification_for_unregister_flag() {
528
529
let expected_value = u64:: try_from ( fds[ 0 ] ) . unwrap ( ) ;
529
530
check_epoll_wait :: < 8 > ( epfd, & [ ( expected_event, expected_value) ] ) ;
530
531
}
532
+
533
+
534
+ fn test_epoll_wait_less_maxevent_zero ( ) {
535
+ // Create an epoll instance.
536
+ let epfd = unsafe { libc:: epoll_create1 ( 0 ) } ;
537
+ assert_ne ! ( epfd, -1 ) ;
538
+ // It is ok to use uninitialised pointer here because it will error out before the
539
+ // pointer actually get accessed.
540
+ let array_ptr = MaybeUninit :: < libc:: epoll_event > :: uninit ( ) . as_mut_ptr ( ) ;
541
+ let res = unsafe { libc:: epoll_wait ( epfd, array_ptr, 0 , 0 ) } ;
542
+ let e = std:: io:: Error :: last_os_error ( ) ;
543
+ assert_eq ! ( e. raw_os_error( ) , Some ( libc:: EINVAL ) ) ;
544
+ assert_eq ! ( res, -1 ) ;
545
+ }
You can’t perform that action at this time.
0 commit comments