diff options
author | itojun <itojun> | 2000-01-17 06:24:23 +0000 |
---|---|---|
committer | itojun <itojun> | 2000-01-17 06:24:23 +0000 |
commit | dff10c7f70d539c431a1eba9ab5e076d8b0f5c8e (patch) | |
tree | 29fbd05a7fa3afbeba9b422f86f9995c166d2eaa | |
parent | 92d3fd1b47a8c041297a3dfa655f0d548012f61c (diff) | |
download | tcpdump-dff10c7f70d539c431a1eba9ab5e076d8b0f5c8e.tar.gz |
s/sprintf/snprintf/.
there seem to be couple of unsafe use of strcat and strcpy - we should
bring in strl{cat,cpy}.
-rw-r--r-- | addrtoname.c | 8 | ||||
-rw-r--r-- | machdep.c | 6 | ||||
-rw-r--r-- | machdep.h | 4 | ||||
-rw-r--r-- | print-ascii.c | 6 | ||||
-rw-r--r-- | print-atalk.c | 12 | ||||
-rw-r--r-- | print-bgp.c | 10 | ||||
-rw-r--r-- | print-decnet.c | 7 | ||||
-rw-r--r-- | print-icmp.c | 53 | ||||
-rw-r--r-- | print-ipx.c | 4 | ||||
-rw-r--r-- | print-isakmp.c | 4 | ||||
-rw-r--r-- | print-ppp.c | 4 | ||||
-rw-r--r-- | print-snmp.c | 15 | ||||
-rw-r--r-- | print-sunrpc.c | 4 | ||||
-rw-r--r-- | print-telnet.c | 13 | ||||
-rw-r--r-- | smbutil.c | 8 | ||||
-rw-r--r-- | tcpdump.c | 4 | ||||
-rw-r--r-- | util.c | 4 |
17 files changed, 89 insertions, 77 deletions
diff --git a/addrtoname.c b/addrtoname.c index 0eba7737..b0ab0059 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -23,7 +23,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.64 1999-11-21 09:36:44 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.65 2000-01-17 06:24:23 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -556,7 +556,7 @@ tcpport_string(u_short port) tp->addr = i; tp->nxt = newhnamemem(); - (void)sprintf(buf, "%u", i); + (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = savestr(buf); return (tp->name); } @@ -575,7 +575,7 @@ udpport_string(register u_short port) tp->addr = i; tp->nxt = newhnamemem(); - (void)sprintf(buf, "%u", i); + (void)snprintf(buf, sizeof(buf), "%u", i); tp->name = savestr(buf); return (tp->name); } @@ -601,7 +601,7 @@ init_servarray(void) while (table->name) table = table->nxt; if (nflag) { - (void)sprintf(buf, "%d", port); + (void)snprintf(buf, sizeof(buf), "%d", port); table->name = savestr(buf); } else table->name = savestr(sv->s_name); @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.5 1999-11-21 09:36:47 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.6 2000-01-17 06:24:23 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -37,13 +37,13 @@ static const char rcsid[] = #include "machdep.h" int -abort_on_misalignment(char *ebuf) +abort_on_misalignment(char *ebuf, size_t ebufsiz) { #ifdef __osf__ static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS }; if (setsysinfo(SSI_NVPAIRS, (caddr_t)buf, 1, 0, 0) < 0) { - (void)sprintf(ebuf, "setsysinfo: errno %d", errno); + (void)snprintf(ebuf, ebufsiz, "setsysinfo: errno %d", errno); return (-1); } #endif @@ -18,10 +18,10 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.1 1999-10-07 23:47:10 mcr Exp $ (LBL) + * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000-01-17 06:24:24 itojun Exp $ (LBL) */ #ifndef tcpdump_machdep_h #define tcpdump_machdep_h -int abort_on_misalignment(char *); +int abort_on_misalignment(char *, size_t); #endif diff --git a/print-ascii.c b/print-ascii.c index 882f2474..a97faf77 100644 --- a/print-ascii.c +++ b/print-ascii.c @@ -42,7 +42,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.4 2000-01-09 21:34:16 fenner Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.5 2000-01-17 06:24:24 itojun Exp $"; #endif #include <stdio.h> #include <sys/types.h> @@ -72,7 +72,7 @@ ascii_print_with_offset(register const u_char *cp, register u_int length, while (--nshorts >= 0) { s1 = *cp++; s2 = *cp++; - (void)sprintf(hsp, " %02x%02x", s1, s2); + (void)snprintf(hsp, sizeof(hsp), " %02x%02x", s1, s2); hsp += HEXDUMP_HEXSTUFF_PER_SHORT; *(asp++) = (isgraph(s1) ? s1 : '.'); *(asp++) = (isgraph(s2) ? s2 : '.'); @@ -87,7 +87,7 @@ ascii_print_with_offset(register const u_char *cp, register u_int length, } if (length & 1) { s1 = *cp++; - (void)sprintf(hsp, " %02x", s1); + (void)snprintf(hsp, sizeof(hsp), " %02x", s1); hsp += 3; *(asp++) = (isgraph(s1) ? s1 : '.'); ++i; diff --git a/print-atalk.c b/print-atalk.c index 5134ebc1..f4df1482 100644 --- a/print-atalk.c +++ b/print-atalk.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.51 1999-11-21 09:36:48 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.52 2000-01-17 06:24:24 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -538,7 +538,8 @@ ataddr_string(u_short atnet, u_char athost) if (tp2->addr == i) { tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); - (void)sprintf(nambuf, "%s.%d", tp2->name, athost); + (void)snprintf(nambuf, sizeof(nambuf), "%s.%d", + tp2->name, athost); tp->name = savestr(nambuf); return (tp->name); } @@ -546,10 +547,11 @@ ataddr_string(u_short atnet, u_char athost) tp->addr = (atnet << 8) | athost; tp->nxt = newhnamemem(); if (athost != 255) - (void)sprintf(nambuf, "%d.%d.%d", + (void)snprintf(nambuf, sizeof(nambuf), "%d.%d.%d", atnet >> 8, atnet & 0xff, athost); else - (void)sprintf(nambuf, "%d.%d", atnet >> 8, atnet & 0xff); + (void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet >> 8, + atnet & 0xff); tp->name = savestr(nambuf); return (tp->name); @@ -569,7 +571,7 @@ ddpskt_string(register int skt) static char buf[8]; if (nflag) { - (void)sprintf(buf, "%d", skt); + (void)snprintf(buf, sizeof(buf), "%d", skt); return (buf); } return (tok2str(skt2str, "%d", skt)); diff --git a/print-bgp.c b/print-bgp.c index bc4cc4ad..e7ecfa4c 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -33,7 +33,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.10 2000-01-09 21:34:17 fenner Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.11 2000-01-17 06:24:24 itojun Exp $"; #endif #include <sys/param.h> @@ -240,7 +240,7 @@ num_or_str(const char **table, size_t siz, int value) { static char buf[20]; if (value < 0 || siz <= value || table[value] == NULL) { - sprintf(buf, "#%d", value); + snprintf(buf, sizeof(buf), "#%d", value); return buf; } else return table[value]; @@ -266,7 +266,7 @@ bgp_notify_minor(int major, int minor) } else p = NULL; if (p == NULL) { - sprintf(buf, "#%d", minor); + snprintf(buf, sizeof(buf), "#%d", minor); return buf; } else return p; @@ -288,7 +288,7 @@ decode_prefix4(const u_char *pd, char *buf, int buflen) ((u_char *)&addr)[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - sprintf(buf, "%s/%d", getname((char *)&addr), plen); + snprintf(buf, buflen, "%s/%d", getname((char *)&addr), plen); return 1 + (plen + 7) / 8; } @@ -309,7 +309,7 @@ decode_prefix6(const u_char *pd, char *buf, int buflen) addr.s6_addr[(plen + 7) / 8 - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } - sprintf(buf, "%s/%d", getname6((char *)&addr), plen); + snprintf(buf, buflen, "%s/%d", getname6((char *)&addr), plen); return 1 + (plen + 7) / 8; } #endif diff --git a/print-decnet.c b/print-decnet.c index aefca10a..4c290f9e 100644 --- a/print-decnet.c +++ b/print-decnet.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.27 1999-11-21 09:36:50 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.28 2000-01-17 06:24:24 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -740,13 +740,14 @@ char * dnnum_string(u_short dnaddr) { char *str; + size_t siz; int area = (u_short)(dnaddr & AREAMASK) >> AREASHIFT; int node = dnaddr & NODEMASK; - str = (char *)malloc(sizeof("00.0000")); + str = (char *)malloc(siz = sizeof("00.0000")); if (str == NULL) error("dnnum_string: malloc"); - sprintf(str, "%d.%d", area, node); + snprintf(str, siz, "%d.%d", area, node); return(str); } diff --git a/print-icmp.c b/print-icmp.c index 5895ce98..38c1fa8f 100644 --- a/print-icmp.c +++ b/print-icmp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999-11-22 04:28:21 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.44 2000-01-17 06:24:25 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -196,9 +196,10 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) case ICMP_UNREACH_PROTOCOL: TCHECK(dp->icmp_ip.ip_p); - (void)sprintf(buf, "%s protocol %d unreachable", - ipaddr_string(&dp->icmp_ip.ip_dst), - dp->icmp_ip.ip_p); + (void)snprintf(buf, sizeof(buf), + "%s protocol %d unreachable", + ipaddr_string(&dp->icmp_ip.ip_dst), + dp->icmp_ip.ip_p); break; case ICMP_UNREACH_PORT: @@ -210,21 +211,21 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) switch (oip->ip_p) { case IPPROTO_TCP: - (void)sprintf(buf, + (void)snprintf(buf, sizeof(buf), "%s tcp port %s unreachable", ipaddr_string(&oip->ip_dst), tcpport_string(dport)); break; case IPPROTO_UDP: - (void)sprintf(buf, + (void)snprintf(buf, sizeof(buf), "%s udp port %s unreachable", ipaddr_string(&oip->ip_dst), udpport_string(dport)); break; default: - (void)sprintf(buf, + (void)snprintf(buf, sizeof(buf), "%s protocol %d port %d unreachable", ipaddr_string(&oip->ip_dst), oip->ip_p, dport); @@ -239,11 +240,11 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) mp = (struct mtu_discovery *)&dp->icmp_void; mtu = EXTRACT_16BITS(&mp->nexthopmtu); if (mtu) - (void)sprintf(buf, + (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag (mtu %d)", ipaddr_string(&dp->icmp_ip.ip_dst), mtu); else - (void)sprintf(buf, + (void)snprintf(buf, sizeof(buf), "%s unreachable - need to frag", ipaddr_string(&dp->icmp_ip.ip_dst)); } @@ -252,7 +253,7 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) default: fmt = tok2str(unreach2str, "#%d %%s unreachable", dp->icmp_code); - (void)sprintf(buf, fmt, + (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(&dp->icmp_ip.ip_dst)); break; } @@ -262,7 +263,7 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) TCHECK(dp->icmp_ip.ip_dst); fmt = tok2str(type2str, "redirect-#%d %%s to net %%s", dp->icmp_code); - (void)sprintf(buf, fmt, + (void)snprintf(buf, sizeof(buf), fmt, ipaddr_string(&dp->icmp_ip.ip_dst), ipaddr_string(&dp->icmp_gwaddr)); break; @@ -278,34 +279,37 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) ihp = (struct ih_rdiscovery *)&dp->icmp_void; TCHECK(*ihp); - (void)strcpy(cp, " lifetime "); + (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf)); cp = buf + strlen(buf); lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); if (lifetime < 60) - (void)sprintf(cp, "%u", lifetime); + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", + lifetime); else if (lifetime < 60 * 60) - (void)sprintf(cp, "%u:%02u", + (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", lifetime / 60, lifetime % 60); else - (void)sprintf(cp, "%u:%02u:%02u", + (void)snprintf(cp, sizeof(buf) - (cp - buf), + "%u:%02u:%02u", lifetime / 3600, (lifetime % 3600) / 60, lifetime % 60); cp = buf + strlen(buf); num = ihp->ird_addrnum; - (void)sprintf(cp, " %d:", num); + (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num); cp = buf + strlen(buf); size = ihp->ird_addrsiz; if (size != 2) { - (void)sprintf(cp, " [size %d]", size); + (void)snprintf(cp, sizeof(buf) - (cp - buf), + " [size %d]", size); break; } idp = (struct id_rdiscovery *)&dp->icmp_data; while (num-- > 0) { TCHECK(*idp); - (void)sprintf(cp, " {%s %u}", + (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}", ipaddr_string(&idp->ird_addr), EXTRACT_32BITS(&idp->ird_pref)); cp = buf + strlen(buf); @@ -326,25 +330,26 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) break; default: - (void)sprintf(buf, "time exceeded-#%d", dp->icmp_code); + (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", + dp->icmp_code); break; } break; case ICMP_PARAMPROB: if (dp->icmp_code) - (void)sprintf(buf, "parameter problem - code %d", - dp->icmp_code); + (void)snprintf(buf, sizeof(buf), + "parameter problem - code %d", dp->icmp_code); else { TCHECK(dp->icmp_pptr); - (void)sprintf(buf, "parameter problem - octet %d", - dp->icmp_pptr); + (void)snprintf(buf, sizeof(buf), + "parameter problem - octet %d", dp->icmp_pptr); } break; case ICMP_MASKREPLY: TCHECK(dp->icmp_mask); - (void)sprintf(buf, "address mask is 0x%08x", + (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", (u_int32_t)ntohl(dp->icmp_mask)); break; diff --git a/print-ipx.c b/print-ipx.c index 83b8330a..a5decb4a 100644 --- a/print-ipx.c +++ b/print-ipx.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.22 1999-11-21 09:36:54 fenner Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.23 2000-01-17 06:24:25 itojun Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -92,7 +92,7 @@ ipxaddr_string(u_int32_t net, const u_char *node) { static char line[256]; - sprintf(line, "%x.%02x:%02x:%02x:%02x:%02x:%02x", + snprintf(line, sizeof(line), "%x.%02x:%02x:%02x:%02x:%02x:%02x", net, node[0], node[1], node[2], node[3], node[4], node[5]); return line; diff --git a/print-isakmp.c b/print-isakmp.c index 8d19c3a8..5f4abc00 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.9 2000-01-07 14:09:02 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.10 2000-01-17 06:24:25 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -989,7 +989,7 @@ static char * numstr(int x) { static char buf[20]; - sprintf(buf, "#%d", x); + snprintf(buf, sizeof(buf), "#%d", x); return buf; } diff --git a/print-ppp.c b/print-ppp.c index 1d242efc..55404ec5 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.33 1999-12-22 06:27:22 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.34 2000-01-17 06:24:26 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -221,7 +221,7 @@ ppp_protoname(int proto) case PPP_CHAP: return "CHAP"; #endif default: - sprintf(buf, "unknown-0x%04x\n", proto); + snprintf(buf, sizeof(buf), "unknown-0x%04x\n", proto); return buf; } } diff --git a/print-snmp.c b/print-snmp.c index b5835dc1..503fc967 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -45,7 +45,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.39 1999-12-22 06:27:22 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.40 2000-01-17 06:24:26 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -188,7 +188,8 @@ char *ErrorStatus[] = { }; #define DECODE_ErrorStatus(e) \ ( e >= 0 && e < sizeof(ErrorStatus)/sizeof(ErrorStatus[0]) \ - ? ErrorStatus[e] : (sprintf(errbuf, "err=%u", e), errbuf)) + ? ErrorStatus[e] \ + : (snprintf(errbuf, sizeof(errbuf), "err=%u", e), errbuf)) /* * generic-trap values in the SNMP Trap-PDU @@ -205,7 +206,8 @@ char *GenericTrap[] = { }; #define DECODE_GenericTrap(t) \ ( t >= 0 && t < sizeof(GenericTrap)/sizeof(GenericTrap[0]) \ - ? GenericTrap[t] : (sprintf(buf, "gt=%d", t), buf)) + ? GenericTrap[t] \ + : (snprintf(buf, sizeof(buf), "gt=%d", t), buf)) /* * ASN.1 type class table @@ -730,11 +732,12 @@ asn1_print(struct be *elem) } d += (elem->data.uns64.low & 0xfffff000); #if 0 /*is looks illegal, but what is the intention???*/ - sprintf(first, "%.f", d); + snprintf(first, sizeof(first), "%.f", d); #else - sprintf(first, "%f", d); + snprintf(first, sizeof(first), "%f", d); #endif - sprintf(last, "%5.5d", elem->data.uns64.low & 0xfff); + snprintf(last, sizeof(last), "%5.5d", + elem->data.uns64.low & 0xfff); for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4; cpl >= last; cpf--, cpl--) { diff --git a/print-sunrpc.c b/print-sunrpc.c index bc4dc5c5..529bf36a 100644 --- a/print-sunrpc.c +++ b/print-sunrpc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.29 1999-11-21 09:37:02 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sunrpc.c,v 1.30 2000-01-17 06:24:26 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -129,7 +129,7 @@ progstr(prog) return (buf); rp = getrpcbynumber(prog); if (rp == NULL) - (void) sprintf(buf, "#%u", prog); + (void) snprintf(buf, sizeof(buf), "#%u", prog); else strcpy(buf, rp->r_name); return (buf); diff --git a/print-telnet.c b/print-telnet.c index beb6be91..cdce8398 100644 --- a/print-telnet.c +++ b/print-telnet.c @@ -51,7 +51,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.5 2000-01-09 21:34:20 fenner Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.6 2000-01-17 06:24:26 itojun Exp $"; #endif #include <sys/param.h> @@ -127,15 +127,16 @@ telnet_print(register const u_char *sp, u_int length) x = *sp++; /* option */ length--; if (x >= 0 && x < NTELOPTS) { - (void)sprintf(tnet, "%s %s", - telcmds[i], telopts[x]); + (void)snprintf(tnet, sizeof(tnet), + "%s %s", telcmds[i], telopts[x]); } else { - (void)sprintf(tnet, "%s %#x", - telcmds[i], x); + (void)snprintf(tnet, sizeof(tnet), + "%s %#x", telcmds[i], x); } break; default: - (void)strcpy(tnet, telcmds[i]); + (void)snprintf(tnet, sizeof(tnet), "%s", + telcmds[i]); } if (c == SB) { c = *sp++; @@ -11,7 +11,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.5 2000-01-09 21:34:20 fenner Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.6 2000-01-17 06:24:27 itojun Exp $"; #endif #include <sys/param.h> @@ -680,17 +680,17 @@ char *smb_errstr(int class,int num) for (j=0;err[j].name;j++) if (num == err[j].code) { - sprintf(ret,"%s - %s (%s)",err_classes[i].class, + snprintf(ret,sizeof(ret),"%s - %s (%s)",err_classes[i].class, err[j].name,err[j].message); return ret; } } - sprintf(ret,"%s - %d",err_classes[i].class,num); + snprintf(ret,sizeof(ret),"%s - %d",err_classes[i].class,num); return ret; } - sprintf(ret,"ERROR: Unknown error (%d,%d)",class,num); + snprintf(ret,sizeof(ret),"ERROR: Unknown error (%d,%d)",class,num); return(ret); } @@ -24,7 +24,7 @@ static const char copyright[] = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\ The Regents of the University of California. All rights reserved.\n"; static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.141 2000-01-15 07:42:32 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.142 2000-01-17 06:24:27 itojun Exp $ (LBL)"; #endif /* @@ -166,7 +166,7 @@ main(int argc, char **argv) else program_name = argv[0]; - if (abort_on_misalignment(ebuf) < 0) + if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0) error("%s", ebuf); #ifdef LIBSMI @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.62 1999-12-15 06:58:03 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.63 2000-01-17 06:24:27 itojun Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -205,7 +205,7 @@ tok2str(register const struct tok *lp, register const char *fmt, } if (fmt == NULL) fmt = "#%d"; - (void)sprintf(buf, fmt, v); + (void)snprintf(buf, sizeof(buf), fmt, v); return (buf); } |