Merge branch 'rw_van_230625' into 'master'
epoll: check for zero or negative size argument See merge request redox-os/relibc!409
This commit is contained in:
@@ -63,6 +63,11 @@ impl PalEpoll for Sys {
|
||||
// TODO: sigset
|
||||
assert_eq!(mem::size_of::<epoll_event>(), mem::size_of::<Event>());
|
||||
|
||||
if maxevents <= 0 {
|
||||
unsafe { platform::errno = EINVAL };
|
||||
return -1;
|
||||
}
|
||||
|
||||
let timer_opt = if timeout != -1 {
|
||||
match File::open(c_str!("time:4"), O_RDWR) {
|
||||
Err(_) => return -1,
|
||||
|
||||
+16
-1
@@ -3,6 +3,7 @@
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
int reader(int fd) {
|
||||
// Create an epoll file
|
||||
@@ -21,8 +22,22 @@ int reader(int fd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Process exactly 1024 events
|
||||
struct epoll_event events[8];
|
||||
|
||||
// Check that epoll returns error on a zero or negative number of events
|
||||
int nfds0 = epoll_wait(epollfd, events, 0, -1);
|
||||
if (nfds0 != -1 || errno != EINVAL) {
|
||||
perror("epoll_wait");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int nfds_n1 = epoll_wait(epollfd, events, -1, -1);
|
||||
if (nfds_n1 != -1 || errno != EINVAL) {
|
||||
perror("epoll_wait");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Process exactly 1024 events
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
// Wait for the next event
|
||||
int nfds = epoll_wait(epollfd, events, sizeof(events)/sizeof(struct epoll_event), -1);
|
||||
|
||||
Reference in New Issue
Block a user