From 4aa19ce98fc4b641b151d2d4a981a88c30ebe570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=BCxen?= Date: Tue, 25 Dec 2012 12:02:39 +0000 Subject: Fix bugs I introduced. Now od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap does work again. svn path=/trunk/; revision=46734 --- text2pcap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'text2pcap.c') diff --git a/text2pcap.c b/text2pcap.c index aa50fc220e..3acc6dedae 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -401,7 +401,7 @@ write_byte (const char *str) num = parse_num(str, FALSE); packet_buf[curr_offset] = (unsigned char) num; curr_offset ++; - if (curr_offset >= max_offset) /* packet full */ + if (curr_offset - header_length >= max_offset) /* packet full */ start_new_packet(); } @@ -414,7 +414,7 @@ write_bytes(const char bytes[], unsigned long nbytes) { unsigned long i; - if (curr_offset + nbytes < max_offset) { + if (curr_offset + nbytes < MAX_PACKET) { for (i = 0; i < nbytes; i++) { packet_buf[curr_offset] = bytes[i]; curr_offset++; @@ -752,7 +752,7 @@ write_current_packet (void) num_packets_written ++; } - packet_start += curr_offset; + packet_start += curr_offset - header_length; curr_offset = header_length; return; } @@ -1074,12 +1074,12 @@ parse_token (token_t token, char *str) break; case T_OFFSET: num = parse_num(str, TRUE); - if (num==0) { + if (num == 0) { /* New packet starts here */ start_new_packet(); packet_start = 0; state = READ_OFFSET; - } else if ((num - packet_start) != curr_offset) { + } else if ((num - packet_start) != curr_offset - header_length) { /* * The offset we read isn't the one we expected. * This may only mean that we mistakenly interpreted @@ -1094,7 +1094,7 @@ parse_token (token_t token, char *str) state = READ_OFFSET; } else { /* Bad offset; switch to INIT state */ - if (debug>=1) + if (debug >= 1) fprintf(stderr, "Inconsistent offset. Expecting %0lX, got %0lX. Ignoring rest of packet\n", curr_offset, num); write_current_packet(); -- cgit v1.2.3