summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-11-03 17:23:07 +0100
committerStefan Metzmacher <metze@samba.org>2009-11-03 18:24:44 +0100
commiteb39f6694055267302580bbf6afa988c82c55fed (patch)
tree0894cebe0b927fee4abf5fcc491ca9f0eea2eddb
parent9b5d1e9e355d3d04f03744e025c6685ca8ad12cd (diff)
downloadsamba-eb39f6694055267302580bbf6afa988c82c55fed.tar.gz
samba-eb39f6694055267302580bbf6afa988c82c55fed.tar.bz2
samba-eb39f6694055267302580bbf6afa988c82c55fed.zip
tsocket_bsd: return -1 and set errno to ENAMETOOLONG if the unix path is too long
metze
-rw-r--r--lib/tsocket/tsocket_bsd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 8f1ccbeb43..05f5be19cb 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -444,9 +444,14 @@ int _tsocket_address_unix_from_path(TALLOC_CTX *mem_ctx,
path = "";
}
+ if (strlen(path) > sizeof(un.sun_path)-1) {
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+
ZERO_STRUCT(un);
un.sun_family = AF_UNIX;
- strncpy(un.sun_path, path, sizeof(un.sun_path));
+ strncpy(un.sun_path, path, sizeof(un.sun_path)-1);
ret = _tsocket_address_bsd_from_sockaddr(mem_ctx,
(struct sockaddr *)p,