diff --git a/osslsigncode.c b/osslsigncode.c index ff899f2..f22083f 100644 --- a/osslsigncode.c +++ b/osslsigncode.c @@ -3651,6 +3651,16 @@ static int use_legacy(void) } #endif /* OPENSSL_VERSION_NUMBER>=0x30000000L */ +static int file_exists(const char *filename) +{ + FILE *file = fopen(filename, "rb"); + if (file) { + fclose(file); + return 1; /* File exists */ + } + return 0; /* File does not exist */ +} + /* * [in] argc, argv * [in, out] options: structure holds the input data @@ -3981,6 +3991,10 @@ static int main_configure(int argc, char **argv, GLOBAL_OPTIONS *options) argc--; } } + if (cmd != CMD_VERIFY && file_exists(options->outfile)) { + printf("Overwriting an existing file is not supported.\n"); + return 0; /* FAILED */ + } if (argc > 0 || #ifdef ENABLE_CURL (options->nturl && options->ntsurl) ||