aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cip.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 15:48:34 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-21 22:49:10 +0000
commit362b83f44a4a6a731c64f8a6591ee717af2454a0 (patch)
tree4b6a22fc76968622a43ef00bc510461e78f0bb30 /epan/dissectors/packet-cip.c
parent1b9d46a9502843c15c33891955f6242c883aa1a5 (diff)
gmtime() can return NULL, even if it's unlikely.
ANSI C says it can return NULL - and, at least on Windows with the MSVC library, it *will* return null for dates prior to the Epoch. Check for a null return and handle it. Fixes CID 1374110. Change-Id: I78bf92cfbb94a86544442269cc3b53338eb19778 Reviewed-on: https://code.wireshark.org/review/18361 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-cip.c')
-rw-r--r--epan/dissectors/packet-cip.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c
index 816b00e5de..bec93471f7 100644
--- a/epan/dissectors/packet-cip.c
+++ b/epan/dissectors/packet-cip.c
@@ -5073,7 +5073,10 @@ static int dissect_cip_attribute(packet_info *pinfo, proto_tree *tree, proto_ite
/* Convert to nstime epoch */
computed_time = CIP_TIMEBASE+(temp_data*60*60*24);
date = gmtime(&computed_time);
- strftime(date_str, 20, "%b %d, %Y", date);
+ if (date != NULL)
+ strftime(date_str, 20, "%b %d, %Y", date);
+ else
+ g_strlcpy(date_str, "Not representable", sizeof date_str);
proto_tree_add_uint_format_value(tree, *(attr->phf), tvb, offset, 2, temp_data, "%s", date_str);
consumed = 2;
break;