aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2007-05-14 13:47:03 +0000
committerUlf Lamping <ulf.lamping@web.de>2007-05-14 13:47:03 +0000
commit013332de7f8fe9f4093d83521be8bfcfa7d17e76 (patch)
treeecec97fa3d7d1018dc69c9cf134d51fb7482b710 /epan/to_str.c
parent25c299ea4e67a891398823beed59f553380fc0f0 (diff)
fix a bug found while fuzz testing the opcua dissector:
MSVC 2005 crashes, if localtime is called with very large numbers (in this case 218939827321) - probably due to changes that time_t is now 64bits long as default limit the number given to localtime to a reasonable value while this isn't a nice fix, I don't see a better way to fix it :-( svn path=/trunk/; revision=21759
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index e73b6596d1..4555b0d64b 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -474,8 +474,17 @@ abs_time_to_str(nstime_t *abs_time)
struct tm *tmp;
gchar *buf;
- buf=ep_alloc(3+1+2+2+4+1+2+1+2+1+2+1+9+1);
-
+ buf=ep_alloc(3+1+2+2+4+1+2+1+2+1+2+1+9+1);
+
+
+#ifdef _MSC_VER
+ /* calling localtime() on MSVC 2005 with huge values causes it to crash */
+ /* XXX - find the exact value that still does work */
+ /* XXX - using _USE_32BIT_TIME_T might be another way to circumvent this problem */
+ if(abs_time->secs > 2000000000) {
+ tmp = NULL;
+ } else
+#endif
tmp = localtime(&abs_time->secs);
if (tmp) {
g_snprintf(buf, 3+1+2+2+4+1+2+1+2+1+2+1+9+1,