aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-03-21 14:09:37 +0100
committerAndreas Schneider <asn@samba.org>2019-03-21 14:09:37 +0100
commit1288ac1f3449db4902bd8218913b40315335828e (patch)
tree7d14a0977c200528c52e9074a48f9af963ba67a7 /src
parentcdeda40cab75f011cb826d0955a8db0b3cf9dbf1 (diff)
downloadsocket_wrapper-1288ac1f3449db4902bd8218913b40315335828e.tar.gz
socket_wrapper-1288ac1f3449db4902bd8218913b40315335828e.tar.xz
socket_wrapper-1288ac1f3449db4902bd8218913b40315335828e.zip
swrap: Add missing NULL checks to socket_wrapper_dir()HEADmaster
This return either malloc'ed memory or NULL. Make sure there is no problem. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index a09851e..5b82e0c 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1819,6 +1819,10 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
}
swrap_dir = socket_wrapper_dir();
+ if (swrap_dir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
if (is_bcast) {
snprintf(un->sun_path, sizeof(un->sun_path),
@@ -1989,6 +1993,10 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
}
swrap_dir = socket_wrapper_dir();
+ if (swrap_dir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
if (prt == 0) {
/* handle auto-allocation of ephemeral ports */
@@ -3583,6 +3591,11 @@ static int swrap_auto_bind(int fd, struct socket_info *si, int family)
}
swrap_dir = socket_wrapper_dir();
+ if (swrap_dir == NULL) {
+ errno = EINVAL;
+ ret = -1;
+ goto done;
+ }
for (i = 0; i < SOCKET_MAX_SOCKETS; i++) {
port = autobind_start + i;
@@ -5388,6 +5401,9 @@ static ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags,
type = SOCKET_TYPE_CHAR_UDP;
swrap_dir = socket_wrapper_dir();
+ if (swrap_dir == NULL) {
+ return -1;
+ }
for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) {
snprintf(un_addr.sa.un.sun_path,
@@ -5893,6 +5909,9 @@ static ssize_t swrap_sendmsg(int s, const struct msghdr *omsg, int flags)
type = SOCKET_TYPE_CHAR_UDP;
swrap_dir = socket_wrapper_dir();
+ if (swrap_dir == NULL) {
+ return -1;
+ }
for(iface=0; iface <= MAX_WRAPPED_INTERFACES; iface++) {
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s/"SOCKET_FORMAT,