posix_sockets: set read/write permissions for socket fd

This commit is contained in:
Martine Lenders 2019-05-24 15:58:50 +02:00
parent 786b7399a3
commit a9ae2f4ac9

View File

@ -19,6 +19,7 @@
#include <assert.h> #include <assert.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
@ -343,7 +344,7 @@ int socket(int domain, int type, int protocol)
case AF_INET6: case AF_INET6:
#endif #endif
{ {
int fd = vfs_bind(VFS_ANY_FD, 0, &socket_ops, s); int fd = vfs_bind(VFS_ANY_FD, O_RDWR, &socket_ops, s);
if (fd < 0) { if (fd < 0) {
errno = ENFILE; errno = ENFILE;
@ -443,7 +444,7 @@ int accept(int socket, struct sockaddr *restrict address,
sa_len); sa_len);
} }
int fd = vfs_bind(VFS_ANY_FD, 0, &socket_ops, new_s); int fd = vfs_bind(VFS_ANY_FD, O_RDWR, &socket_ops, new_s);
if (fd < 0) { if (fd < 0) {
errno = ENFILE; errno = ENFILE;
res = -1; res = -1;