From 2aad70eb9ecbd01c3137d1e7d2a879baa38889bb Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Mon, 20 Aug 2001 11:58:05 +0000 Subject: [PATCH] Don't misuse the return from snprintf. MFC after: 2 weeks --- usr.bin/netstat/atalk.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index b2dd3829cedf..45e465c571a1 100644 --- a/usr.bin/netstat/atalk.c +++ b/usr.bin/netstat/atalk.c @@ -200,14 +200,16 @@ atalk_print2(struct sockaddr *sa, struct sockaddr *mask, int what) sa2 = (struct sockaddr *)&thesockaddr; thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net & sat2->sat_addr.s_net; - n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 |(what & 8))); + snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 |(what & 8))); if(sat2->sat_addr.s_net != 0xFFFF) { thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net | ~sat2->sat_addr.s_net; - n += snprintf(buf + n, sizeof(buf) - n, - "-%s", atalk_print(sa2, 1 |(what & 8))); + n = strlen(buf); + snprintf(buf + n, sizeof(buf) - n, "-%s", atalk_print(sa2, 1 |(what & 8))); + } + if(what & 2) { + n = strlen(buf); + snprintf(buf + n, sizeof(buf) - n, ".%s", atalk_print(sa, what & (~1))); } - if(what & 2) - n += snprintf(buf + n, sizeof(buf) - n, ".%s", atalk_print(sa, what&(~1))); return(buf); }