]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod-client.c: Avoid freeing uninitialized value
authorAaron Merey <amerey@redhat.com>
Sat, 25 Jan 2025 00:43:19 +0000 (19:43 -0500)
committerAaron Merey <amerey@redhat.com>
Sat, 25 Jan 2025 00:43:19 +0000 (19:43 -0500)
debuginfod_validate_imasig might call free on an uninitialized sig_buf
due to a goto that can occur before sig_buf is set to NULL.

Fix this by setting sig_buf to NULL before the goto.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/debuginfod-client.c

index deff19ff4568a9be2915b93b44a283fccfd50844..d89beae93ea1d8f6b3aa62017c1b404919d6d79d 100644 (file)
@@ -1587,6 +1587,7 @@ debuginfod_validate_imasig (debuginfod_client *c, int fd)
 {
   int rc = ENOSYS;
 
+    char* sig_buf = NULL;
     EVP_MD_CTX *ctx = NULL;
     if (!c || !c->winning_headers)
     {
@@ -1594,7 +1595,6 @@ debuginfod_validate_imasig (debuginfod_client *c, int fd)
       goto exit_validate;
     }
     // Extract the HEX IMA-signature from the header
-    char* sig_buf = NULL;
     char* hdr_ima_sig = strcasestr(c->winning_headers, "x-debuginfod-imasignature");
     if (!hdr_ima_sig || 1 != sscanf(hdr_ima_sig + strlen("x-debuginfod-imasignature:"), "%ms", &sig_buf))
     {