]> granicus.if.org Git - p11-kit/commitdiff
trust: Fix use after free and double free in extract command
authorStef Walter <stef@thewalter.net>
Fri, 8 Aug 2014 15:19:50 +0000 (17:19 +0200)
committerStef Walter <stef@thewalter.net>
Fri, 8 Aug 2014 16:44:20 +0000 (18:44 +0200)
trust/extract.c

index b93571babfdb6ee9e49cca0ae609c8427e40a1a3..1bc406c68666f62cb21ad28245e3de54fcdb03dc 100644 (file)
@@ -289,7 +289,6 @@ p11_trust_extract_compat (int argc,
                           char *argv[])
 {
        char *path = NULL;
-       char *path2 = NULL;
        int error;
 
        argv[argc] = NULL;
@@ -298,24 +297,22 @@ p11_trust_extract_compat (int argc,
         * For compatibility with people who deployed p11-kit 0.18.x
         * before trust stuff was put into its own branch.
         */
-       path2 = p11_path_build (PRIVATEDIR, "p11-kit-extract-trust", NULL);
-       return_val_if_fail (path2 != NULL, 1);
-       execv (path2, argv);
+       path = p11_path_build (PRIVATEDIR, "p11-kit-extract-trust", NULL);
+       return_val_if_fail (path != NULL, 1);
+       execv (path, argv);
        error = errno;
-       free (path2);
 
        if (error == ENOENT) {
+               free (path);
                path = p11_path_build (PRIVATEDIR, "trust-extract-compat", NULL);
                return_val_if_fail (path != NULL, 1);
                execv (path, argv);
                error = errno;
-               free (path);
        }
 
        /* At this point we have no command */
        p11_message_err (error, "could not run %s command", path);
 
        free (path);
-       free (path2);
        return 2;
 }