summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2012-12-10 17:14:12 +0100
committerGünther Deschner <gd@samba.org>2012-12-12 15:00:02 +0100
commit7dd13503c0919766ecf3c8f5f48cda72aae8ac73 (patch)
tree0d5f27e09176abf43a947a34114f72e0195185ca
parent07385a851f6c07c9f8ef4414d8483de7106ee486 (diff)
downloadsamba-7dd13503c0919766ecf3c8f5f48cda72aae8ac73.tar.gz
samba-7dd13503c0919766ecf3c8f5f48cda72aae8ac73.tar.bz2
samba-7dd13503c0919766ecf3c8f5f48cda72aae8ac73.zip
s4-socket: Make sure unix socket addresses are null terminated.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Günther Deschner <gd@samba.org>
-rw-r--r--source4/lib/socket/socket_unix.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index 2909ecca8f..4755e796a4 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -113,7 +113,7 @@ static NTSTATUS unixdom_connect(struct socket_context *sock,
ZERO_STRUCT(srv_addr);
srv_addr.sun_family = AF_UNIX;
- strncpy(srv_addr.sun_path, srv_address->addr, sizeof(srv_addr.sun_path));
+ snprintf(srv_addr.sun_path, sizeof(srv_addr.sun_path), "%s", srv_address->addr);
ret = connect(sock->fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));
}
@@ -148,8 +148,8 @@ static NTSTATUS unixdom_listen(struct socket_context *sock,
ZERO_STRUCT(my_addr);
my_addr.sun_family = AF_UNIX;
- strncpy(my_addr.sun_path, my_address->addr, sizeof(my_addr.sun_path));
-
+ snprintf(my_addr.sun_path, sizeof(my_addr.sun_path), "%s", my_address->addr);
+
ret = bind(sock->fd, (struct sockaddr *)&my_addr, sizeof(my_addr));
}
if (ret == -1) {
@@ -278,8 +278,8 @@ static NTSTATUS unixdom_sendto(struct socket_context *sock,
ZERO_STRUCT(srv_addr);
srv_addr.sun_family = AF_UNIX;
- strncpy(srv_addr.sun_path, dest->addr, sizeof(srv_addr.sun_path));
-
+ snprintf(srv_addr.sun_path, sizeof(srv_addr.sun_path), "%s", dest->addr);
+
len = sendto(sock->fd, blob->data, blob->length, 0,
(struct sockaddr *)&srv_addr, sizeof(srv_addr));
}