aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2011-06-09 18:27:11 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2011-06-09 18:27:11 +0000
commit90e539b55f72ae42a753b008220086aa69c22087 (patch)
tree30ddbcd0201693397c260a7d6fc9fbc13a721b33 /editcap.c
parent08dcc378489904543fec2414a3fa0245f08259b7 (diff)
downloadwireshark-90e539b55f72ae42a753b008220086aa69c22087.tar.gz
wireshark-90e539b55f72ae42a753b008220086aa69c22087.tar.bz2
wireshark-90e539b55f72ae42a753b008220086aa69c22087.zip
Simplify timestamp checking: only check the packet's timestamp if
check_startstop is set. Refuse to write packets that do not fit in the file type we're writing. This allows fuzz testing to be done on JPEGs without generating bogus files (with packets bigger than the maximum packet size). This fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6010 . Note that this is only a problem with editcap is run with -T to force the encapsulation type. Maybe this needs a more generic solution (e.g., should this check be done in the wiretap routines?), but at least for now it'll pacify the buildbot. svn path=/trunk/; revision=37633
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/editcap.c b/editcap.c
index ae9306736e..de06752b44 100644
--- a/editcap.c
+++ b/editcap.c
@@ -831,7 +831,7 @@ main(int argc, char *argv[])
int split_packet_count = 0;
int written_count = 0;
char *filename = NULL;
- gboolean check_ts;
+ gboolean ts_okay = TRUE;
int secs_per_block = 0;
int block_cnt = 0;
nstime_t block_start;
@@ -1208,10 +1208,10 @@ main(int argc, char *argv[])
}
}
- check_ts = check_timestamp(wth);
+ if (check_startstop)
+ ts_okay = check_timestamp(wth);
- if ( ((check_startstop && check_ts) || (!check_startstop && !check_ts)) && ((!selected(count) && !keep_em) ||
- (selected(count) && keep_em)) ) {
+ if ( ts_okay && ((!selected(count) && !keep_em) || (selected(count) && keep_em)) ) {
if (verbose && !dup_detect && !dup_detect_by_time)
printf("Packet: %u\n", count);
@@ -1440,6 +1440,12 @@ main(int argc, char *argv[])
}
}
+ if(phdr->caplen > wtap_snapshot_length(wth)) {
+ fprintf(stderr, "Warning: packet %d too big for file type, skipping it...\n", count);
+ count++;
+ continue;
+ }
+
if (!wtap_dump(pdh, phdr, wtap_pseudoheader(wth), buf, &err)) {
fprintf(stderr, "editcap: Error writing to %s: %s\n",
filename, wtap_strerror(err));