1
0
mirror of https://github.com/PHJArea217/socket-enhancer synced 2024-11-22 08:51:00 +02:00

EFAULT on NULL address

This commit is contained in:
Peter H. Jin 2021-06-16 18:26:11 -05:00
parent 4c60187a6b
commit 253dda436d

View File

@ -203,6 +203,10 @@ static int try_preconnect_bind_v6(int fd, const struct ipv6_with_scope *bind_add
return config->real_bind(fd, (struct sockaddr *) &existing_address, sizeof(existing_address));
}
int connect(int fd, const struct sockaddr *addr_, socklen_t len_) {
if (!addr_) {
errno = EFAULT;
return -1;
}
const struct sockaddr *addr = addr_;
socklen_t len = len_;
union {
@ -273,6 +277,10 @@ int connect(int fd, const struct sockaddr *addr_, socklen_t len_) {
return config->real_connect(fd, addr, len);
}
int bind(int fd, const struct sockaddr *addr_, socklen_t len_) {
if (!addr_) {
errno = EFAULT;
return -1;
}
struct socket_enhancer_config *config = __atomic_load_n(&global_config, __ATOMIC_SEQ_CST);
if (!config) abort();
int always_freebind = !!(config->always_freebind & 1);