use a better method to copy labels; formerly, bad parameters could
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 24 Sep 2004 15:08:26 +0000 (15:08 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 24 Sep 2004 15:08:26 +0000 (15:08 +0000)
cause undefined behaviour

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1713 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/lib/syscall_setvhiname-v13.hc

index 4bee1ba..2d98099 100644 (file)
@@ -34,7 +34,8 @@ vc_set_vhi_name_v13(xid_t xid, vc_uts_type type, char const *val, size_t len)
   }
 
   cmd.field = VHI_USER2KERNEL(type);
-  strncpy(cmd.name, val, sizeof(cmd.name));
+  memcpy(cmd.name, val, len);
+  cmd.name[len] = '\0';
 
   rc = vserver(VCMD_vx_set_vhi_name, CTX_USER2KERNEL(xid), &cmd);
   ENSC_FIX_IOCTL(rc);