snprintf(... "%s"...) => safe_strncpy
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 4 Jun 2007 21:03:51 +0000 (21:03 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 4 Jun 2007 21:03:51 +0000 (21:03 -0000)
networking/libiproute/utils.c

index 7fc1dbc..a0d0824 100644 (file)
@@ -316,9 +316,12 @@ const char *format_host(int af, int len, void *addr, char *buf, int buflen)
                        default:;
                        }
                }
-               if (len > 0 && (h_ent = gethostbyaddr(addr, len, af)) != NULL) {
-                       snprintf(buf, buflen - 1, "%s", h_ent->h_name);
-                       return buf;
+               if (len > 0) {
+                       h_ent = gethostbyaddr(addr, len, af);
+                       if (h_ent != NULL) {
+                               safe_strncpy(buf, h_ent->h_name, buflen);
+                               return buf;
+                       }
                }
        }
 #endif