Opened 15 years ago
Closed 15 years ago
#3973 closed bug (fixed)
ioctl FIONREAD does not propagate errors
Reported by: | titer | Owned by: | mmlr |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Network & Internet | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Test case with a not connected socket:
#include <stdio.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/socket.h> int main() { int fd = socket(AF_INET, SOCK_STREAM, 0); int n = 0x42; int ret = ioctl(fd, FIONREAD, &n); printf("ret %d, n %d / %X\n", ret, n, n); return 0; }
gives:
ret 0, n -2147454946 / 8000701E
The ioctl should return -1 and set errno, rather than saying there are ENOTCONN bytes available for reading.
I noticed this from running libevent tests - since ioctl returns 0, it (legitimately IMO) assumes the value is >= 0 and ends up trying to allocate some GBs of memory.
Haiku hrev30805 gcc4
Note:
See TracTickets
for help on using tickets.
Looking into it.