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 7fc1dbc266d9a01f18b904394b37b54005eeebc0..a0d08246a4c33943ca62c497542c905d38ee874c 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