From f1ee951aaf455fcdb978617bf3c2c28f5e62b772 Mon Sep 17 00:00:00 2001 From: Egor Ignatov Date: Fri, 26 Jan 2024 17:32:56 +0300 Subject: [PATCH] wincert: ignore empty cert list in finalize_signatures Signed-off-by: Egor Ignatov --- src/wincert.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wincert.c b/src/wincert.c index a6d9b4c..ea8a025 100644 --- a/src/wincert.c +++ b/src/wincert.c @@ -73,7 +73,11 @@ finalize_signatures(SECItem **sigs, int num_sigs, Pe *pe) void *clist = NULL; size_t clist_size = 0; - if (!pe) { + if (num_sigs == 0) { + return 0; + } + + if (!pe || num_sigs < 0) { errno = EINVAL; return -1; } @@ -82,9 +86,11 @@ finalize_signatures(SECItem **sigs, int num_sigs, Pe *pe) &clist, &clist_size) < 0) return -1; - if (implant_cert_list(pe, clist, clist_size) < 0) { - free(clist); - return -1; + if (clist_size > 0) { + if (implant_cert_list(pe, clist, clist_size) < 0) { + free(clist); + return -1; + } } free(clist); return 0;