]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gcrypt: Always initialize result pointer.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 10 Jul 2016 18:59:34 +0000 (20:59 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 22 Aug 2016 15:27:51 +0000 (17:27 +0200)
If the call to mmap_full_file() at the beginning of decode_key() fails,
we return without initializing the result pointer to NULL. This does not
matter now, because the only caller of decode_key() does not look at the
pointer value in the error case. Let's be defensive here and initialize
the pointer anyway.

gcrypt.c

index 45a1c67d20da0b6d229180de92be10644a63d082..63f8fff3e788d5166410736b6bc95d425f112f0f 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -212,7 +212,7 @@ static int decode_key(const char *key_file, const char *header_str,
 
        ret = mmap_full_file(key_file, O_RDONLY, &map, &map_size, NULL);
        if (ret < 0)
 
        ret = mmap_full_file(key_file, O_RDONLY, &map, &map_size, NULL);
        if (ret < 0)
-               return ret;
+               goto out;
        ret = -E_KEY_MARKER;
        if (strncmp(map, header_str, strlen(header_str)))
                goto unmap;
        ret = -E_KEY_MARKER;
        if (strncmp(map, header_str, strlen(header_str)))
                goto unmap;
@@ -257,6 +257,7 @@ unmap:
                free(blob);
                blob = NULL;
        }
                free(blob);
                blob = NULL;
        }
+out:
        *result = blob;
        return ret;
 }
        *result = blob;
        return ret;
 }