diff options
author | brian <brian@FreeBSD.org> | 2001-08-20 11:58:05 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-20 11:58:05 +0000 |
commit | e5aeafb88ac1c0cc0a8ad38e45fc3ba78dd10c08 (patch) | |
tree | 4b1077319b9c70c5f40dcad83c69eb41854ef13d | |
parent | 7ac94dd0fbb990675214c8e4a267b5a3f597f707 (diff) | |
download | FreeBSD-src-e5aeafb88ac1c0cc0a8ad38e45fc3ba78dd10c08.zip FreeBSD-src-e5aeafb88ac1c0cc0a8ad38e45fc3ba78dd10c08.tar.gz |
Don't misuse the return from snprintf.
MFC after: 2 weeks
-rw-r--r-- | usr.bin/netstat/atalk.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index b2dd382..45e465c 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); } |