about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-01-24 02:39:26 +0000
committerMiles Bader <miles@gnu.org>1996-01-24 02:39:26 +0000
commit6d5cbf7b35bdbfe5bc9675842b2cf595f12288cc (patch)
treeecf2600c41feaeaceb4ec56d8fa8ec91e678c358 /sysdeps
parentfd86137937b2be15f18c6564f39aa51fd0c48b00 (diff)
downloadglibc-6d5cbf7b35bdbfe5bc9675842b2cf595f12288cc.tar.gz
glibc-6d5cbf7b35bdbfe5bc9675842b2cf595f12288cc.tar.xz
glibc-6d5cbf7b35bdbfe5bc9675842b2cf595f12288cc.zip
(bind): Ensure NAME for the AF_LOCAL case is '\0'-terminated.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/bind.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/bind.c b/sysdeps/mach/hurd/bind.c
index 11f268be09..a6ebc1ea34 100644
--- a/sysdeps/mach/hurd/bind.c
+++ b/sysdeps/mach/hurd/bind.c
@@ -42,8 +42,11 @@ DEFUN(bind, (fd, addr, len),
       /* For the local domain, we must create a node in the filesystem
 	 using the ifsock translator and then fetch the address from it.  */
       file_t dir, node;
-      char name[len - offsetof (struct sockaddr_un, sun_path)], *n;
-      strncpy (name, addr->sun_path, sizeof name);
+      char name[len - offsetof (struct sockaddr_un, sun_path) + 1], *n;
+
+      strncpy (name, addr->sun_path, sizeof name - 1);
+      name[sizeof name - 1] = '\0'; /* Make sure */
+
       dir = __file_name_split (name, &n);
       if (dir == MACH_PORT_NULL)
 	return -1;