diff options
author | Guy Harris <gharris@sonic.net> | 2022-08-16 15:46:26 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-08-16 15:46:26 -0700 |
commit | 7bc6771397bcd2b4ac9c14f7d72dc4c8d4500fc0 (patch) | |
tree | 83be8a79072ec8dfd4a8c5be313f4656007b9a63 /wiretap | |
parent | 79219b5247fcb0010536d857de460e1179967fc2 (diff) |
visual: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509368.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/visual.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/wiretap/visual.c b/wiretap/visual.c index 0897a55f3e..f0fa86ea33 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -136,7 +136,7 @@ struct visual_read_info /* Additional information for writing Visual files */ struct visual_write_info { - time_t start_time; /* Capture start time in seconds */ + guint32 start_time; /* Capture start time in seconds */ int index_table_index; /* Index of the next index entry */ int index_table_size; /* Allocated size of the index table */ guint32 * index_table; /* File offsets for the packets */ @@ -678,8 +678,18 @@ static gboolean visual_dump(wtap_dumper *wdh, const wtap_rec *rec, file start time. */ if (visual->index_table_index == 0) { - /* This is the first packet. Save its start time as the file time. */ - visual->start_time = rec->ts.secs; + /* + * This is the first packet. Save its start time as the file time. + * + * XXX - is the start time signed, or unsigned? If it's signed, + * in which case we should check against G_MININT32 and G_MAXINT32 + * and make start_time a gint32. + */ + if (rec->ts.secs < 0 || rec->ts.secs > G_MAXUINT32) { + *err = WTAP_ERR_TIME_STAMP_NOT_SUPPORTED; + return FALSE; + } + visual->start_time = (guint32)rec->ts.secs; /* Initialize the index table */ visual->index_table = (guint32 *)g_malloc(1024 * sizeof *visual->index_table); |