Actions
Bug #15889
opengetsockopt(3socket) fails for small option_len
Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:
Description
POSIX says: If the size of the option value is greater than option_len , the value stored in the object pointed to by the option_value argument shall be silently truncated.
But illumos does this:
$ cat <<EOF > test.c #include <sys/types.h> #include <sys/socket.h> #include <stdio.h> int main(void) { int f = socket(AF_INET, SOCK_DGRAM, 0); printf("f: %d\n", f); char buf[16]; int len = sizeof buf; int ret = getsockopt(f, SOL_SOCKET, SO_REUSEADDR, buf, &len); printf("ret: %d, len: %d\n", ret, len); len = 1; ret = getsockopt(f, SOL_SOCKET, SO_REUSEADDR, buf, &len); printf("ret: %d, len: %d\n", ret, len); return 0; } EOF $ /usr/gcc/10/bin/gcc -Wall -lsocket -lnsl test.c $ ./a.out f: 3 ret: 0, len: 4 ret: -1, len: 1 $
The exactly same code on linux works properly:
$ ./a.out f: 3 ret: 0, len: 4 ret: 0, len: 1 $
No data to display
Actions