From 38d632bec68a9be8c78670d829526577a87cf9c5 Mon Sep 17 00:00:00 2001 From: gerald Date: Fri, 15 Apr 2005 21:38:42 +0000 Subject: In time_secs_to_str_buf(), handle the case where a large time value makes things go wonky. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@14097 f5534014-38df-0310-8fa8-9805f1628bb7 --- epan/to_str.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'epan/to_str.c') diff --git a/epan/to_str.c b/epan/to_str.c index fec83d10a1..17d8207681 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -364,7 +364,7 @@ vines_addr_to_str_buf(const guint8 *addrp, gchar *buf) * (Does not include the terminating '\0'.) * Includes space for a '-' sign for any negative compunents. */ -#define TIME_SECS_LEN (8+1+4+2+2+5+2+2+7+2+2+7+4) +#define TIME_SECS_LEN (10+1+4+2+2+5+2+2+7+2+2+7+4) /* * Convert a value in seconds and fractions of a second to a string, @@ -388,6 +388,11 @@ time_secs_to_str_buf(gint32 time, guint32 frac, gboolean is_nsecs, msign="-"; } + if(time<0){ /* We've overflowed. */ + sprintf(buf, "Unable to cope with time value %d", time); + return; + } + secs = time % 60; time /= 60; mins = time % 60; @@ -395,6 +400,7 @@ time_secs_to_str_buf(gint32 time, guint32 frac, gboolean is_nsecs, hours = time % 24; time /= 24; + /* This would probably be cleaner if we used GStrings instead. */ p = buf; if (time != 0) { sprintf(p, "%s%u day%s", time?msign:"", time, PLURALIZE(time)); -- cgit v1.2.3