]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Initialize subst rule->result pointer to NULL 790/head
authorGraham Percival <gperciva@tarsnap.com>
Wed, 28 Sep 2016 18:02:34 +0000 (11:02 -0700)
committerGraham Percival <gperciva@tarsnap.com>
Wed, 28 Sep 2016 18:02:34 +0000 (11:02 -0700)
This is not directly useful in libarchive at the present time, but
it might be in the future.  If a project which uses this code adds
an atexit(3) handler to clean up memory, and somebody runs:
    bsdtar somestring -t
then "omestring" will be interpreted as an (invalid) substitution
rule and call lafe_errc().  However, if the atexit() handler then
calls cleanup_substition(), it will try to free(rule->result)
which was not initialized.

Sponsored by: Tarsnap Backup Inc.

tar/subst.c

index 4710e06a623a81b0609efc76745cf8a0dab13988..39c54acfd14f070eb886a01d081550570d7fe066 100644 (file)
@@ -84,6 +84,7 @@ add_substitution(struct bsdtar *bsdtar, const char *rule_text)
        if (rule == NULL)
                lafe_errc(1, errno, "Out of memory");
        rule->next = NULL;
+       rule->result = NULL;
 
        if (subst->last_rule == NULL)
                subst->first_rule = rule;