diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-07-15 19:14:03 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-07-15 19:14:03 +0000 |
commit | b7255e108a8e22f9fc458ad644e43e9475f51fd0 (patch) | |
tree | 868384d9df93246ae15a0650cf5fdcc47b65cb23 /epan | |
parent | e574c8de6d5cd2684265ce041539614c8872f781 (diff) | |
download | wireshark-b7255e108a8e22f9fc458ad644e43e9475f51fd0.tar.gz |
Fixes, from Scott Renfro, for some calls to "localtime()" that didn't
check whether the call succeeded (it doesn't always do so on Windows,
for example).
svn path=/trunk/; revision=3722
Diffstat (limited to 'epan')
-rw-r--r-- | epan/column-utils.c | 38 | ||||
-rw-r--r-- | epan/to_str.c | 23 |
2 files changed, 36 insertions, 25 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index 3a44cf66ba..15c8776a89 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -1,7 +1,7 @@ /* column-utils.c * Routines for column utilities. * - * $Id: column-utils.c,v 1.3 2001/04/02 10:38:26 guy Exp $ + * $Id: column-utils.c,v 1.4 2001/07/15 19:14:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -248,15 +248,19 @@ col_set_abs_date_time(frame_data *fd, int col) then = fd->abs_secs; tmp = localtime(&then); - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, - "%04d-%02d-%02d %02d:%02d:%02d.%04ld", - tmp->tm_year + 1900, - tmp->tm_mon + 1, - tmp->tm_mday, - tmp->tm_hour, - tmp->tm_min, - tmp->tm_sec, - (long)fd->abs_usecs/100); + if (tmp != NULL) { + snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, + "%04d-%02d-%02d %02d:%02d:%02d.%04ld", + tmp->tm_year + 1900, + tmp->tm_mon + 1, + tmp->tm_mday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)fd->abs_usecs/100); + } else { + fd->cinfo->col_buf[col][0] = '\0'; + } fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; } @@ -286,11 +290,15 @@ col_set_abs_time(frame_data *fd, int col) then = fd->abs_secs; tmp = localtime(&then); - snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld", - tmp->tm_hour, - tmp->tm_min, - tmp->tm_sec, - (long)fd->abs_usecs/100); + if (tmp != NULL) { + snprintf(fd->cinfo->col_buf[col], COL_MAX_LEN, "%02d:%02d:%02d.%04ld", + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)fd->abs_usecs/100); + } else { + fd->cinfo->col_buf[col][0] = '\0'; + } fd->cinfo->col_data[col] = fd->cinfo->col_buf[col]; } diff --git a/epan/to_str.c b/epan/to_str.c index bbf8e97ed0..26229c2be3 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -1,7 +1,7 @@ /* to_str.h * Routines for utilities to convert various other types to strings. * - * $Id: to_str.c,v 1.9 2001/07/13 00:27:51 guy Exp $ + * $Id: to_str.c,v 1.10 2001/07/15 19:14:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -411,15 +411,18 @@ abs_time_to_str(struct timeval *abs_time) } tmp = localtime(&abs_time->tv_sec); - sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%06ld", - mon_names[tmp->tm_mon], - tmp->tm_mday, - tmp->tm_year + 1900, - tmp->tm_hour, - tmp->tm_min, - tmp->tm_sec, - (long)abs_time->tv_usec); - + if (tmp) { + sprintf(cur, "%s %2d, %d %02d:%02d:%02d.%06ld", + mon_names[tmp->tm_mon], + tmp->tm_mday, + tmp->tm_year + 1900, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec, + (long)abs_time->tv_usec); + } else { + strncpy(cur, "Not representable", sizeof(str[0])); + } return cur; } |