aboutsummaryrefslogtreecommitdiffstats
path: root/editcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-01-18 11:19:36 -0800
committerGuy Harris <guy@alum.mit.edu>2018-01-18 19:20:18 +0000
commitb0c0490fe073b19e1d67d928bc22c64666f8a48b (patch)
treed3292a39c9933e5178a4335b2fc7b8bd39b9ab71 /editcap.c
parent682fe39422b01fe850a8718766766f5f32ecf908 (diff)
Don't overwrite the struct wtap_pkthdr; copy and change it instead.
Do as we do in other cases - copy the current struct wtap_pkthdr to a temporary one (which might copy the temporary one to itself), modify it, and set the pointer to the struct wtap_pkthdr to point to the temporary one. Note all the places wherw we do this with a comment. Change-Id: Ia11df6b997a5369d96436d3bd825ab0138742504 Reviewed-on: https://code.wireshark.org/review/25377 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'editcap.c')
-rw-r--r--editcap.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/editcap.c b/editcap.c
index 8eb414c60a..37fd3baa55 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1526,7 +1526,10 @@ main(int argc, char *argv[])
}
}
- /* CHOP */
+ /*
+ * CHOP
+ * Copy and change rather than modify returned phdr.
+ */
temp_phdr = *phdr;
handle_chopping(chop, &temp_phdr, phdr, &buf, adjlen);
phdr = &temp_phdr;
@@ -1551,6 +1554,8 @@ main(int argc, char *argv[])
* that it is being compared to. This is NOT a normal
* situation since trace files usually have packets in
* chronological order (oldest to newest).
+ * Copy and change rather than modify
+ * returned phdr.
*/
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
temp_phdr = *phdr;
@@ -1570,6 +1575,8 @@ main(int argc, char *argv[])
* A negative strict time adjustment is requested.
* Unconditionally set each timestamp to previous
* packet's timestamp plus delta.
+ * Copy and change rather than modify returned
+ * phdr.
*/
temp_phdr = *phdr;
temp_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
@@ -1588,6 +1595,7 @@ main(int argc, char *argv[])
}
if (time_adj.tv.secs != 0) {
+ /* Copy and change rather than modify returned phdr */
temp_phdr = *phdr;
if (time_adj.is_negative)
temp_phdr.ts.secs -= time_adj.tv.secs;
@@ -1597,6 +1605,7 @@ main(int argc, char *argv[])
}
if (time_adj.tv.nsecs != 0) {
+ /* Copy and change rather than modify returned phdr */
temp_phdr = *phdr;
if (time_adj.is_negative) { /* subtract */
if (temp_phdr.ts.nsecs < time_adj.tv.nsecs) { /* borrow */
@@ -1619,8 +1628,10 @@ main(int argc, char *argv[])
/* remove vlan info */
if (rem_vlan) {
- /* TODO: keep casting const like this? change pointer instead of value? */
- remove_vlan_info(phdr, buf, (guint32 *) &phdr->caplen);
+ /* Copy and change rather than modify returned phdr */
+ temp_phdr = *phdr;
+ remove_vlan_info(phdr, buf, &temp_phdr.caplen);
+ phdr = &temp_phdr;
}
/* suppress duplicates by packet window */
@@ -1751,6 +1762,7 @@ main(int argc, char *argv[])
temp_phdr.has_comment_changed = TRUE;
phdr = &temp_phdr;
} else {
+ /* Copy and change rather than modify returned phdr */
temp_phdr = *phdr;
temp_phdr.has_comment_changed = FALSE;
phdr = &temp_phdr;