]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx.c: Pre-initialize timezone to avoid crash on destroy
authorScott Griepentrog <sgriepentrog@digium.com>
Wed, 22 Jan 2014 22:23:16 +0000 (22:23 +0000)
committerScott Griepentrog <sgriepentrog@digium.com>
Wed, 22 Jan 2014 22:23:16 +0000 (22:23 +0000)
In ast_build_timing, initialize the timezone value to NULL
in order to avoid deferencing an uninitialized value later
when calling ast_destroy_timing.  The timezone value could
be uninitialized if ast_build_timing were to fail due to a
zero length time string.

(closes issue ASTERISK-22861)
Reported by: Sebastian Murray-Roberts
Review: https://reviewboard.asterisk.org/r/3134/
Patches:
     ast_build_timing-initialize-timezone.patch uploaded by coreyfarrell (license 5909)
........

Merged revisions 406241 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 406245 from http://svn.asterisk.org/svn/asterisk/branches/11

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

main/pbx.c
utils/extconf.c

index 5ec4979212f8d86937b73dd493c5c0c29298017b..efeddaf6bb061b19b5efce96ee71b174c97f29c2 100644 (file)
@@ -9154,6 +9154,8 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        char *info;
        int j, num_fields, last_sep = -1;
 
+       i->timezone = NULL;
+
        /* Check for empty just in case */
        if (ast_strlen_zero(info_in)) {
                return 0;
@@ -9173,8 +9175,6 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        /* save the timezone, if it is specified */
        if (num_fields == 5) {
                i->timezone = ast_strdup(info + last_sep + 1);
-       } else {
-               i->timezone = NULL;
        }
 
        /* Assume everything except time */
index a31fe283ade896c2e74943cd21e1b1d36a005cf2..981a64e61a4779c907ea4e149dd13315f2e98d6e 100644 (file)
@@ -4454,6 +4454,8 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        char *info;
        int j, num_fields, last_sep = -1;
 
+       i->timezone = NULL;
+
        /* Check for empty just in case */
        if (ast_strlen_zero(info_in)) {
                return 0;
@@ -4473,8 +4475,6 @@ int ast_build_timing(struct ast_timing *i, const char *info_in)
        /* save the timezone, if it is specified */
        if (num_fields == 5) {
                i->timezone = ast_strdup(info + last_sep + 1);
-       } else {
-               i->timezone = NULL;
        }
 
        /* Assume everything except time */