aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorMinh Phan <phanducnhatminh@gmail.com>2020-05-25 10:35:09 +0800
committerAnders Broman <a.broman58@gmail.com>2020-06-01 06:51:55 +0000
commit88aec0ecd92a27625c213720afcef62f596538c6 (patch)
tree45e3d63c9a410415cf2ca7bee1cc386855348818 /wiretap
parent0b179d901eef8b954f1cb3f7c97cfed0a6240d3e (diff)
editcap: fix time adjustment for ERF
The erf_dump function in erf.c keeps the header intact and ignores the adjusted time. This adds a section for checking if the timestamp is changed and updating the header accordingly. Bug: 16578 Change-Id: I14468a302e746c7a84cf5619b73b94850142d930 Reviewed-on: https://code.wireshark.org/review/37301 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/erf.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c
index ebd47a68c4..b63fe3e1a6 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -1872,6 +1872,26 @@ static gboolean erf_dump(
other_phdr.erf.phdr.wlen = (guint16)total_wlen;
pseudo_header = &other_phdr;
+ } else if (rec->presence_flags & WTAP_HAS_TS) {
+ // Update timestamp if changed.
+ time_t secs;
+ int nsecs;
+ guint64 ts = pseudo_header->erf.phdr.ts;
+
+ secs = (long) (ts >> 32);
+ ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
+ ts += (ts & 0x80000000) << 1; /* rounding */
+ nsecs = ((int) (ts >> 32));
+ if (nsecs >= 1000000000) {
+ nsecs -= 1000000000;
+ secs += 1;
+ }
+
+ if (secs != rec->ts.secs || nsecs != rec->ts.nsecs) {
+ other_phdr = *pseudo_header;
+ other_phdr.erf.phdr.ts = ((guint64) rec->ts.secs << 32) + (((guint64) rec->ts.nsecs <<32) / 1000 / 1000 / 1000);
+ pseudo_header = &other_phdr;
+ }
}
/* We now have a (real or fake) ERF record */