diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-10-21 19:18:15 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-10-22 02:27:32 +0000 |
commit | 10ca4c7527122efde0300205deaa6c0143f07219 (patch) | |
tree | 5352128043afff3b586c4a314ab2d240aec36f6a /epan/tvbuff.c | |
parent | 49cf42c571f3f94632957371ccd99533e71764ff (diff) |
More checks for localtime() and gmtime() returning NULL.
And some comments in the case where we're converting the result of
time() - if your machine's idea of time predates January 1, 1970,
00:00:00 UTC, it'll crash on Windows, but that's not a case where a
*file* can cause the problem due either to a bad file time stamp or bad
time stamps in the file.
Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498
Reviewed-on: https://code.wireshark.org/review/18369
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 8919131344..3358b7ae1f 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -1580,9 +1580,16 @@ tvb_get_string_time(tvbuff_t *tvb, const gint offset, const gint length, /* setting it to "now" for now */ time_t time_now = time(NULL); struct tm *tm_now = gmtime(&time_now); - tm.tm_year = tm_now->tm_year; - tm.tm_mon = tm_now->tm_mon; - tm.tm_mday = tm_now->tm_mday; + if (tm_now != NULL) { + tm.tm_year = tm_now->tm_year; + tm.tm_mon = tm_now->tm_mon; + tm.tm_mday = tm_now->tm_mday; + } else { + /* The second before the Epoch */ + tm.tm_year = 69; + tm.tm_mon = 12; + tm.tm_mday = 31; + } end = ptr + num_chars; errno = 0; |