X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/34ff77ff4318038a1c9f8d31e4bb50ad5ba10cd1..64e81f2917f6865dff8df96e18cec1b8bf2fa836:/print-telnet.c diff --git a/print-telnet.c b/print-telnet.c index beb6be91..67aa666e 100644 --- a/print-telnet.c +++ b/print-telnet.c @@ -51,34 +51,28 @@ #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.12 2000-09-29 04:58:51 guy Exp $"; #endif #include #include #include +#include #include -#include -#include -#include -#include #define TELCMDS #define TELOPTS #include #include -#ifdef __STDC__ #include -#endif #include #include #include "interface.h" #include "addrtoname.h" - #ifndef TELCMD_FIRST # define TELCMD_FIRST SE #endif @@ -127,15 +121,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++; @@ -173,11 +168,13 @@ telnet_print(register const u_char *sp, u_int length) hex_print_with_offset(osp, i, off); off += i; if (i > 8) - printf("\n\t\t\t\t%s", tnet); + printf("\n\t\t\t\t"); else - printf("%*s\t%s", (8 - i) * 3, "", tnet); + printf("%*s\t", (8 - i) * 3, ""); + safeputs(tnet); } else { - printf("%s%s", (first) ? " [telnet " : ", ", tnet); + printf("%s", (first) ? " [telnet " : ", "); + safeputs(tnet); } first = 0; }