From 10ca4c7527122efde0300205deaa6c0143f07219 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 21 Oct 2016 19:18:15 -0700 Subject: 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 --- ringbuffer.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index 7f0f67d5e7..099e8c4783 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -102,6 +102,12 @@ static int ringbuf_open_file(rb_file *rfile, int *err) current_time = time(NULL); g_snprintf(filenum, sizeof(filenum), "%05u", (rb_data.curr_file_num + 1) % RINGBUFFER_MAX_NUM_FILES); + /* + * XXX - We trust Windows not to return a time before the Epoch, so + * localtime() doesn't return a null pointer. localtime() can probably + * handle pre-Epoch times on most UN*X systems, and we trust them not + * to return a time before the Epoch in any case. + */ strftime(timestr, sizeof(timestr), "%Y%m%d%H%M%S", localtime(¤t_time)); rfile->name = g_strconcat(rb_data.fprefix, "_", filenum, "_", timestr, rb_data.fsuffix, NULL); -- cgit v1.2.3