From ef5047038e0557cf059f54033387bfa4ca459601 Mon Sep 17 00:00:00 2001 From: olszomal <Malgorzata.Olszowka@stunnel.org> Date: Tue, 7 Nov 2023 13:17:37 +0100 Subject: [PATCH] Delete the output file in case of error --- appx.c | 7 +++++++ osslsigncode.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/appx.c b/appx.c index 712c346..70c6f05 100644 --- a/appx.c +++ b/appx.c @@ -709,6 +709,13 @@ static void appx_ctx_cleanup(FILE_FORMAT_CTX *ctx, BIO *hash, BIO *outdata) if (outdata) { BIO_free_all(hash); BIO_free_all(outdata); + if (ctx->options->outfile) { +#ifdef WIN32 + _unlink(ctx->options->outfile); +#else + unlink(ctx->options->outfile); +#endif /* WIN32 */ + } } freeZip(ctx->appx_ctx->zip); OPENSSL_free(ctx->appx_ctx->calculatedBMHash); diff --git a/osslsigncode.c b/osslsigncode.c index c652baa..ff899f2 100644 --- a/osslsigncode.c +++ b/osslsigncode.c @@ -4076,6 +4076,13 @@ int main(int argc, char **argv) ret = 1; /* FAILED */ BIO_free_all(hash); BIO_free_all(outdata); + if (options.outfile) { +#ifdef WIN32 + _unlink(options.outfile); +#else + unlink(options.outfile); +#endif /* WIN32 */ + } DO_EXIT_0("Initialization error or unsupported input file type.\n"); } if (options.cmd == CMD_VERIFY) {