aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2014-11-11 15:22:12 -0500
committerMichael Mann <mmann78@netscape.net>2014-11-12 03:33:15 +0000
commit219cf304c1a028f4010ba8868d6bd8f6ae70541d (patch)
tree48f303d7b273802c33aecf6c9d84fd032acd925f
parentcfd71d7c2a736e2a4b65e6119778148808abe2fe (diff)
Fix SMPP timestamp decoding when the current date/time's offset to UTC is
different from the timestamp's offset to UTC. The fix for bug 6712 ignored the fact that daylight savings will affect the offset from UTC--and whether daylight savings is in effect today might be different than whether it was in effect in the timestamp we're decoding. Bug: 10672 Change-Id: Ie513c361cff41007f2328cd9ca9ca4800ffef500 Reviewed-on: https://code.wireshark.org/review/5245 Petri-Dish: Michael Mann <mmann78@netscape.net> Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-smpp.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c
index a067a02e5f..5bfac61b80 100644
--- a/epan/dissectors/packet-smpp.c
+++ b/epan/dissectors/packet-smpp.c
@@ -1180,34 +1180,35 @@ smpp_mktime(const char *datestr, time_t *secs, int *nsecs)
if (relative == FALSE) {
struct tm *gm, *local_time;
int gm_hour, gm_min;
- time_t current_time;
*secs = mktime(&r_time);
+ *nsecs = (datestr[12] - '0') * 100000000;
+
+ t_diff = (10 * (datestr[13] - '0') + (datestr[14] - '0')) * 900;
+ if (datestr[15] == '-')
+ /* Represented time is behind UTC, shift it forward to UTC */
+ *secs += t_diff;
+ else if (datestr[15] == '+')
+ /* Represented time is ahead of UTC, shift it backward to UTC */
+ *secs -= t_diff;
- /* Subtract out the timezone information since we will adjust for
- * the presented time's timezone below and then display in UTC.
+ /* Subtract out the timezone information since we adjusted for
+ * the presented time's timezone above and will display in UTC.
*
- * To do that, first determine the current timezone's offset to UTC.
+ * To do that, first determine how the time is represented in the
+ * local time zone and in UTC.
*/
- current_time = time(NULL);
- gm = gmtime(&current_time);
+ gm = gmtime(secs);
gm_hour = gm->tm_hour;
gm_min = gm->tm_min;
- local_time = localtime(&current_time);
- /* Then subtract out that difference (whether the difference is
- * measured in hours, minutes, or both).
+ local_time = localtime(secs);
+
+ /* Then subtract out the difference between those times (whether the
+ * difference is measured in hours, minutes, or both).
*/
*secs -= 3600*(gm_hour - local_time->tm_hour);
*secs -= 60*(gm_min - local_time->tm_min);
- *nsecs = (datestr[12] - '0') * 100000000;
- t_diff = (10 * (datestr[13] - '0') + (datestr[14] - '0')) * 900;
- if (datestr[15] == '-')
- /* Represented time is behind UTC, shift it forward to UTC */
- *secs += t_diff;
- else if (datestr[15] == '+')
- /* Represented time is ahead of UTC, shift it backward to UTC */
- *secs -= t_diff;
} else {
*secs = r_time.tm_sec + 60 *
(r_time.tm_min + 60 *