From 8f9e830a943f44ef2b548270ef78feee15e1f6cb Mon Sep 17 00:00:00 2001 From: Egor Ignatov Date: Thu, 16 Nov 2023 10:50:49 +0300 Subject: [PATCH] pesign: Remove the first signature unless another is specified Signed-off-by: Egor Ignatov --- src/file_pe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/file_pe.c b/src/file_pe.c index 805e614..cb42e51 100644 --- a/src/file_pe.c +++ b/src/file_pe.c @@ -231,8 +231,9 @@ pe_handle_action(pesign_context *ctxp, int action, int padding) open_input(ctxp); open_output(ctxp); close_input(ctxp); - if(ctxp->signum < 0 || - ctxp->signum >= ctxp->cms_ctx->num_signatures) { + if (ctxp->signum < 0) + ctxp->signum = 0; + if (ctxp->signum >= ctxp->cms_ctx->num_signatures) { warnx("Invalid signature number %d.", ctxp->signum); errx(1, "Must be between 0 and %d.",