Commit 7ae4aa56 authored by Mike Frysinger's avatar Mike Frysinger

get_sname: avoid buffer overflows if proto name is too long

Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent 6a9347cb
......@@ -431,16 +431,17 @@ const char *get_sname(int socknumber, const char *proto, int numeric)
init = 1;
}
buffer[0] = '\0';
if (!strcmp(proto, "tcp")) {
if ((item = searchlist(tcp_name, socknumber)) != NULL)
sprintf(buffer, "%s", item->name);
} else if (!strcmp(proto, "udp")) {
if ((item = searchlist(udp_name, socknumber)) != NULL)
sprintf(buffer, "%s", item->name);
} else if (!strcmp(proto, "raw")) {
if ((item = searchlist(raw_name, socknumber)) != NULL)
sprintf(buffer, "%s", item->name);
if (!strcmp(proto, "tcp"))
item = searchlist(tcp_name, socknumber);
else if (!strcmp(proto, "udp"))
item = searchlist(udp_name, socknumber);
else if (!strcmp(proto, "raw"))
item = searchlist(raw_name, socknumber);
else
item = NULL;
if (item) {
strncpy(buffer, item->name, sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0';
}
if (!buffer[0]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment