snprintf(... "%s"...) => safe_strncpy

This commit is contained in:
Denis Vlasenko 2007-06-04 21:03:51 +00:00
parent 3c8b5ba8e8
commit 8c1aaf3297

View File

@ -316,11 +316,14 @@ const char *format_host(int af, int len, void *addr, char *buf, int buflen)
default:; default:;
} }
} }
if (len > 0 && (h_ent = gethostbyaddr(addr, len, af)) != NULL) { if (len > 0) {
snprintf(buf, buflen - 1, "%s", h_ent->h_name); h_ent = gethostbyaddr(addr, len, af);
if (h_ent != NULL) {
safe_strncpy(buf, h_ent->h_name, buflen);
return buf; return buf;
} }
} }
}
#endif #endif
return rt_addr_n2a(af, len, addr, buf, buflen); return rt_addr_n2a(af, len, addr, buf, buflen);
} }