diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-23 22:40:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-06-23 22:40:56 +0000 |
commit | 30cb72a00b8cc59895c391cad0f8e31611611ec4 (patch) | |
tree | 3e2f67dd80af3489363cf0596b740c6533994e40 /usr.bin/netstat/atalk.c | |
parent | 325437057bbda9490b174c8fc6dc8f0e14a8f145 (diff) |
Fix snprintf return value usage.
Diffstat (limited to 'usr.bin/netstat/atalk.c')
-rw-r--r-- | usr.bin/netstat/atalk.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index f6b33c45fb1..d57aa91b3bf 100644 --- a/usr.bin/netstat/atalk.c +++ b/usr.bin/netstat/atalk.c @@ -219,7 +219,7 @@ atalk_print2(sa, mask, what) const struct sockaddr *mask; int what; { - int n; + size_t n, l; static char buf[100]; struct sockaddr_at *sat1, *sat2; struct sockaddr_at thesockaddr; @@ -232,15 +232,24 @@ atalk_print2(sa, mask, what) 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))); + if (n >= sizeof(buf)) + n = sizeof(buf) - 1; 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, + l = snprintf(buf + n, sizeof(buf) - n, "-%s", atalk_print(sa2, 1 | (what & 8))); + if (l >= sizeof(buf) - n) + l = sizeof(buf) - n - 1; + n += l; } - if (what & 2) - n += snprintf(buf + n, sizeof(buf) - n, ".%s", + if (what & 2) { + l = snprintf(buf + n, sizeof(buf) - n, ".%s", atalk_print(sa, what & (~1))); + if (l >= sizeof(buf) - n) + l = sizeof(buf) - n - 1; + n += l; + } return (buf); } |