summaryrefslogtreecommitdiff
path: root/ui/gtk/rtp_analysis.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 19:18:15 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-22 02:27:32 +0000
commit10ca4c7527122efde0300205deaa6c0143f07219 (patch)
tree5352128043afff3b586c4a314ab2d240aec36f6a /ui/gtk/rtp_analysis.c
parent49cf42c571f3f94632957371ccd99533e71764ff (diff)
downloadwireshark-10ca4c7527122efde0300205deaa6c0143f07219.tar.gz
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 'ui/gtk/rtp_analysis.c')
-rw-r--r--ui/gtk/rtp_analysis.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c
index 239f8569da..0089624909 100644
--- a/ui/gtk/rtp_analysis.c
+++ b/ui/gtk/rtp_analysis.c
@@ -570,14 +570,20 @@ rtp_packet_add_info(GtkWidget *list, user_data_t * user_data,
then = pinfo->abs_ts.secs;
msecs = (guint16)(pinfo->abs_ts.nsecs/1000000);
tm_tmp = localtime(&then);
- g_snprintf(timeStr, sizeof(timeStr), "%02d/%02d/%04d %02d:%02d:%02d.%03d",
- tm_tmp->tm_mon + 1,
- tm_tmp->tm_mday,
- tm_tmp->tm_year + 1900,
- tm_tmp->tm_hour,
- tm_tmp->tm_min,
- tm_tmp->tm_sec,
- msecs);
+ if (tm_tmp != NULL) {
+ /*
+ * XXX - somewhat US-centric.
+ */
+ g_snprintf(timeStr, sizeof(timeStr), "%02d/%02d/%04d %02d:%02d:%02d.%03d",
+ tm_tmp->tm_mon + 1,
+ tm_tmp->tm_mday,
+ tm_tmp->tm_year + 1900,
+ tm_tmp->tm_hour,
+ tm_tmp->tm_min,
+ tm_tmp->tm_sec,
+ msecs);
+ } else
+ g_snprintf(timeStr, sizeof(timeStr), "XX/XX/XXXX XX:XX:XX.XXX");
/* Default to using black on white text if nothing below overrides it */
g_snprintf(color_str, sizeof(color_str), "#ffffffffffff");