aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/inet.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/inet.c b/lib/inet.c
index 073c8a3..60e55df 100644
--- a/lib/inet.c
+++ b/lib/inet.c
@@ -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]) {