summaryrefslogtreecommitdiff
path: root/print-ascii.c
diff options
context:
space:
mode:
authoritojun <itojun>2000-01-29 16:47:46 +0000
committeritojun <itojun>2000-01-29 16:47:46 +0000
commitc87b499eac2cdd7e48e25154a9942f839cc6b8b7 (patch)
treefbc160cd25285bfa946c7df06c9ae579f20e1435 /print-ascii.c
parent8cf2e80eedbad56ce1498a43d355c0c4078c0f15 (diff)
downloadtcpdump-c87b499eac2cdd7e48e25154a9942f839cc6b8b7.tar.gz
fix ascii dump with -X. due to mistake in snprintf() fixes.
(no need to pull into 3.5)
Diffstat (limited to 'print-ascii.c')
-rw-r--r--print-ascii.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/print-ascii.c b/print-ascii.c
index a97faf77..c8f65fd3 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.5 2000-01-17 06:24:24 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.6 2000-01-29 16:47:46 itojun Exp $";
#endif
#include <stdio.h>
#include <sys/types.h>
@@ -72,7 +72,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
while (--nshorts >= 0) {
s1 = *cp++;
s2 = *cp++;
- (void)snprintf(hsp, sizeof(hsp), " %02x%02x", s1, s2);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
*(asp++) = (isgraph(s1) ? s1 : '.');
*(asp++) = (isgraph(s2) ? s2 : '.');
@@ -87,7 +88,8 @@ ascii_print_with_offset(register const u_char *cp, register u_int length,
}
if (length & 1) {
s1 = *cp++;
- (void)snprintf(hsp, sizeof(hsp), " %02x", s1);
+ (void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
+ " %02x", s1);
hsp += 3;
*(asp++) = (isgraph(s1) ? s1 : '.');
++i;