From bde2a9493b8e74e98cd3babbcc9fdf364634c69f Mon Sep 17 00:00:00 2001 From: Chris Maynard Date: Fri, 15 Nov 2013 22:31:11 +0000 Subject: [PATCH] Fix chopping when offset is 0. Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9422 svn path=/trunk/; revision=53345 --- editcap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/editcap.c b/editcap.c index 535cc35bae..1e9587d755 100644 --- a/editcap.c +++ b/editcap.c @@ -178,7 +178,7 @@ static nstime_t previous_time = {0, 0}; /* previous time */ static int find_dct2000_real_data(guint8 *buf); static void handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr, - const struct wtap_pkthdr *in_phdr, guint8 *buf, + const struct wtap_pkthdr *in_phdr, guint8 **buf, gboolean adjlen); static gchar * @@ -1327,7 +1327,7 @@ main(int argc, char *argv[]) /* CHOP */ snap_phdr = *phdr; - handle_chopping(chop, &snap_phdr, phdr, buf, adjlen); + handle_chopping(chop, &snap_phdr, phdr, &buf, adjlen); phdr = &snap_phdr; /* Do we adjust timestamps to ensure strict chronological @@ -1642,7 +1642,7 @@ find_dct2000_real_data(guint8 *buf) */ static void handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr, - const struct wtap_pkthdr *in_phdr, guint8 *buf, + const struct wtap_pkthdr *in_phdr, guint8 **buf, gboolean adjlen) { /* If we're not chopping anything from one side, then the offset for that @@ -1694,11 +1694,11 @@ handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr, *out_phdr = *in_phdr; if (chop.off_begin_pos > 0) { - memmove(&buf[chop.off_begin_pos], - &buf[chop.off_begin_pos + chop.len_begin], + memmove(*buf + chop.off_begin_pos, + *buf + chop.off_begin_pos + chop.len_begin, out_phdr->caplen - chop.len_begin); } else { - buf += chop.len_begin; + *buf += chop.len_begin; } out_phdr->caplen -= chop.len_begin; @@ -1717,8 +1717,8 @@ handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr, *out_phdr = *in_phdr; if (chop.off_end_neg < 0) { - memmove(&buf[(gint)out_phdr->caplen + (chop.len_end + chop.off_end_neg)], - &buf[(gint)out_phdr->caplen + chop.off_end_neg], + memmove(*buf + (gint)out_phdr->caplen + (chop.len_end + chop.off_end_neg), + *buf + (gint)out_phdr->caplen + chop.off_end_neg, -chop.off_end_neg); } out_phdr->caplen += chop.len_end;