aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2017-02-07 23:35:50 +0100
committerPeter Wu <peter@lekensteyn.nl>2017-02-08 22:31:43 +0000
commitb28b07379fe966f0a89ead9fe2fa30ac05e19e9c (patch)
treeac220e970e06863d9a3833597f341dc1ff037327 /editcap.c
parentedf5ae3fba16c8ed761ec5a55095e59fe96c7647 (diff)
editcap: handle too short frames in frame comparison
With option -I one can ignore the first number of bytes from the frame while doing duplicate frame removal. This doesn't handle shorter frames correctly. Add safeguards for this, and update the help text. Bug: 13378 Change-Id: Ia6b65d0797f4069f0b89fa134114d88d80988211 Reviewed-on: https://code.wireshark.org/review/20004 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/editcap.c b/editcap.c
index f2da469e41..43aa6a3b08 100644
--- a/editcap.c
+++ b/editcap.c
@@ -581,11 +581,16 @@ is_duplicate(guint8* fd, guint32 len) {
md5_state_t ms;
/*Hint to ignore some bytes at the start of the frame for the digest calculation(-I option) */
+ guint32 offset = ignored_bytes;
guint32 new_len;
guint8 *new_fd;
- new_fd = &fd[ignored_bytes];
- new_len = len - (ignored_bytes);
+ if (len <= ignored_bytes) {
+ offset = 0;
+ }
+
+ new_fd = &fd[offset];
+ new_len = len - (offset);
cur_dup_entry++;
if (cur_dup_entry >= dup_window)
@@ -618,11 +623,16 @@ is_duplicate_rel_time(guint8* fd, guint32 len, const nstime_t *current) {
md5_state_t ms;
/*Hint to ignore some bytes at the start of the frame for the digest calculation(-I option) */
+ guint32 offset = ignored_bytes;
guint32 new_len;
guint8 *new_fd;
- new_fd = &fd[ignored_bytes];
- new_len = len - (ignored_bytes);
+ if (len <= ignored_bytes) {
+ offset = 0;
+ }
+
+ new_fd = &fd[offset];
+ new_len = len - (offset);
cur_dup_entry++;
if (cur_dup_entry >= dup_window)
@@ -752,8 +762,9 @@ print_usage(FILE *output)
fprintf(output, " (e.g. 0.000001).\n");
fprintf(output, " -a <framenum>:<comment> Add or replace comment for given frame number\n");
fprintf(output, "\n");
- fprintf(output, " -I <bytes to ignore> ignore the specified bytes at the beginning of\n");
- fprintf(output, " the frame during MD5 hash calculation.\n");
+ fprintf(output, " -I <bytes to ignore> ignore the specified number of bytes at the beginning\n");
+ fprintf(output, " of the frame during MD5 hash calculation, unless the\n");
+ fprintf(output, " frame is too short, then the full frame is used.\n");
fprintf(output, " Useful to remove duplicated packets taken on\n");
fprintf(output, " several routers (different mac addresses for\n");
fprintf(output, " example).\n");