aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-04-28 13:16:29 -0700
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-04-28 21:31:15 +0000
commiteb4d68033e33b6aa23b293ee070c5c799381aba4 (patch)
tree1e81772f1a82352dc8c091fcef5ba2e6ac888f63 /wiretap
parent21b334fd827c9e37c8973ab7e6625784726be243 (diff)
Don't cast away upper bits when assigning to a nstime_t's secs field.
The secs field is a time_t, which is not necessarily 32 bits. If it's not, casting away the upper bits, by casting to guint32, introduces a Y2.038K bug. Either cast to time_t or, if you're assigning a time_t to it, don't bother with the cast.
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/k12.c2
-rw-r--r--wiretap/pcap-common.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/wiretap/k12.c b/wiretap/k12.c
index d9ee211c92..b63e979964 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -600,7 +600,7 @@ process_packet_data(wtap_rec *rec, Buffer *target, guint8 *buffer,
ts = pntoh64(buffer + K12_PACKET_TIMESTAMP);
- rec->ts.secs = (guint32) ((ts / 2000000) + 631152000);
+ rec->ts.secs = (time_t) ((ts / 2000000) + 631152000);
rec->ts.nsecs = (guint32) ( (ts % 2000000) * 500 );
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen = length;
diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c
index 328833121c..6b1136ac4b 100644
--- a/wiretap/pcap-common.c
+++ b/wiretap/pcap-common.c
@@ -1433,7 +1433,7 @@ pcap_read_erf_pseudoheader(FILE_T fh, wtap_rec *rec,
* This allows an ultimate resolution of 1/(2^32) seconds, or approximately 233 picoseconds */
if (rec) {
guint64 ts = pseudo_header->erf.phdr.ts;
- rec->ts.secs = (guint32) (ts >> 32);
+ rec->ts.secs = (time_t) (ts >> 32);
ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
ts += (ts & 0x80000000) << 1; /* rounding */
rec->ts.nsecs = ((guint32) (ts >> 32));