Whamcloud - gitweb
LU-4629 libcfs: fix buffer overflow of string buffer
[fs/lustre-release.git] / libcfs / libcfs / hash.c
index 0c4faf8..dda925c 100644 (file)
@@ -1056,8 +1056,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits,
         if (hs == NULL)
                 RETURN(NULL);
 
-       strncpy(hs->hs_name, name, len);
-       hs->hs_name[len - 1] = '\0';
+       strlcpy(hs->hs_name, name, len);
        hs->hs_flags = flags;
 
        atomic_set(&hs->hs_refcount, 1);