]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
funcs/func_cdr: Handle empty time values when extracting parsed values
authorMatthew Jordan <mjordan@digium.com>
Fri, 7 Feb 2014 19:40:23 +0000 (19:40 +0000)
committerMatthew Jordan <mjordan@digium.com>
Fri, 7 Feb 2014 19:40:23 +0000 (19:40 +0000)
When extracting timestamps that are parsed, time stamp values that are not set
(time values of 0.000000) should not actually result in a parsed string. The
value should be skipped, and the result of the CDR function should be an
empty string.

Prior to this patch, the result was fed to the time formatting, which would
result in an output of a date/time in 1969.
........

Merged revisions 407747 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407748 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_cdr.c

index ce5a126867dda2042eb46519e363600008f3826c..0116eee7fa5644cf03f429d6a07f67e46124598d 100644 (file)
@@ -291,9 +291,13 @@ static void cdr_read_callback(void *data, struct stasis_subscription *sub, struc
                                        args.variable, tempbuf, ast_channel_name(payload->chan));
                                return;
                        }
-                       fmt_time.tv_usec = tv_usec;
-                       ast_localtime(&fmt_time, &tm, NULL);
-                       ast_strftime(tempbuf, sizeof(tempbuf), "%Y-%m-%d %T", &tm);
+                       if (fmt_time.tv_sec) {
+                               fmt_time.tv_usec = tv_usec;
+                               ast_localtime(&fmt_time, &tm, NULL);
+                               ast_strftime(tempbuf, sizeof(tempbuf), "%Y-%m-%d %T", &tm);
+                       } else {
+                               tempbuf[0] = '\0';
+                       }
                } else if (!strcasecmp("disposition", args.variable)) {
                        int disposition;