Whamcloud - gitweb
LU-4629 libcfs: fix buffer overflow of string buffer
[fs/lustre-release.git] / lnet / utils / portals.c
index 2a8684c..7161f6b 100644 (file)
@@ -152,8 +152,7 @@ ptl_ipaddr_2_str(__u32 ipaddr, char *str, size_t strsize, int lookup)
                 net_ip = htonl (ipaddr);
                 he = gethostbyaddr (&net_ip, sizeof (net_ip), AF_INET);
                 if (he != NULL) {
-                       strncpy(str, he->h_name, strsize - 1);
-                       str[strsize - 1] = '\0';
+                       strlcpy(str, he->h_name, strsize);
                         return (str);
                 }
         }