From 7a81add848378117b5dd7759f83c2c3c72befaa7 Mon Sep 17 00:00:00 2001 From: Bill Meier Date: Mon, 19 Jan 2015 15:19:46 -0500 Subject: [PATCH] synphasor: prevent possible crash; gmtime() can return NULL; Don't do manual conversion of a time-field to UTC using gmtime(). Use the standard Wireshark mechanisms. Change-Id: I2eaee074a590ecab492336bb6ad794bdd036f699 Reviewed-on: https://code.wireshark.org/review/6661 Reviewed-by: Bill Meier --- epan/dissectors/packet-synphasor.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index bfe62a0ada..34bf59df33 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -604,16 +604,8 @@ static gint dissect_header(tvbuff_t *tvb, proto_tree *tree) offset += 2; /* SOC */ - { - /* can't use 'proto_tree_add_time()' because we need UTC */ - char buf[20]; - struct tm* t; - time_t soc = tvb_get_ntohl(tvb, offset); - t = gmtime(&soc); - strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", t); - proto_tree_add_string(tree, hf_soc, tvb, offset, 4, buf); - offset += 4; - } + proto_tree_add_item(tree, hf_soc, tvb, offset, 4, ENC_TIME_TIMESPEC | ENC_BIG_ENDIAN); + offset += 4; /* FRACSEC */ /* time quality flags */ @@ -1169,7 +1161,7 @@ void proto_register_synphasor(void) NULL, 0x0, NULL, HFILL }}, { &hf_soc, - { "SOC time stamp (UTC)", "synphasor.soc", FT_STRINGZ, BASE_NONE, + { "SOC time stamp", "synphasor.soc", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL }}, /* Time quality flags in fracsec */