diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tsocket/tsocket_bsd.c | 7 |
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, |