snprintf(... "%s"...) => safe_strncpy
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c
index 7fc1dbc..a0d0824 100644
--- a/networking/libiproute/utils.c
+++ b/networking/libiproute/utils.c
@@ -316,9 +316,12 @@
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