zipl: extract_signature: fix memory leak of @signature

Fix memory leak @signature in case of an unsupported signature type.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2023-03-13 19:29:04 +01:00
committed by Steffen Eiden
parent 21dbbcfa56
commit 0e86da9d66

View File

@@ -511,9 +511,6 @@ extract_signature(const char *filename, void **ret_signature,
memcpy(signature, buffer + size - signature_size - sizeof(*file_sig),
signature_size);
*ret_signature = signature;
sig_head->length = signature_size;
switch (file_sig->id_type) {
case PKEY_ID_PKCS7:
sig_head->format = PKCS7_FORMAT;
@@ -522,8 +519,12 @@ extract_signature(const char *filename, void **ret_signature,
error_text("Unsupported signature type %02x",
file_sig->id_type);
signature_size = 0;
free(signature);
goto out;
}
sig_head->length = signature_size;
*ret_signature = signature;
/* return size of signature and corresponding header */
signature_size += sizeof(*file_sig);
out: