aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-08-16 17:19:20 -0700
committerGuy Harris <gharris@sonic.net>2022-08-16 17:19:20 -0700
commit7411bc298b5133e9cd685d3af8ce23881bb7178f (patch)
tree863f03e4ffb3c91661ef31ad1ec5b3725299f971 /wiretap
parentefea61f405c5fb32e1d99d0cd528a17e9b15df5d (diff)
nettl: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509360.
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/nettl.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index e2b5a472c1..251040db58 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -697,7 +697,17 @@ static gboolean nettl_dump(wtap_dumper *wdh,
/* HP-UX 11.X header should be 68 bytes */
rec_hdr.hdr_len = g_htons(sizeof(rec_hdr) + 4);
rec_hdr.kind = g_htonl(NETTL_HDR_PDUIN);
- rec_hdr.sec = g_htonl(rec->ts.secs);
+ /*
+ * Probably interpreted as signed in other programs that read it.
+ * Maybe HPE will decide to make it unsigned, which could probably
+ * be made to work once the last 32-bit UN*X is gone and time_t
+ * is universally 64-bit.
+ */
+ if (rec->ts.secs < 0 || rec->ts.secs > G_MAXINT32) {
+ *err = WTAP_ERR_TIME_STAMP_NOT_SUPPORTED;
+ return FALSE;
+ }
+ rec_hdr.sec = g_htonl((guint32)rec->ts.secs);
rec_hdr.usec = g_htonl(rec->ts.nsecs/1000);
rec_hdr.caplen = g_htonl(rec->rec_header.packet_header.caplen);
rec_hdr.length = g_htonl(rec->rec_header.packet_header.len);