From 3820c150d1e67e50cca06707f1e401867a0f03a7 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 9 Dec 2021 12:48:51 +0000 Subject: [PATCH] Prevent resource leak If -f was used as an argument twice to the program, then it would leak the file resource, due to overwriting it on the second pass Signed-off-by: Paul Elliott --- programs/ssl/ssl_context_info.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c index 5ad9120321..999bfe89b2 100644 --- a/programs/ssl/ssl_context_info.c +++ b/programs/ssl/ssl_context_info.c @@ -219,7 +219,13 @@ void parse_arguments( int argc, char *argv[] ) error_exit(); } - if( ( b64_file = fopen( argv[i], "r" ) ) == NULL ) + if( NULL != b64_file ) + { + printf_err( "Cannot specify more than one file with -f\n" ); + error_exit( ); + } + + if( ( b64_file = fopen( argv[i], "r" )) == NULL ) { printf_err( "Cannot find file \"%s\"\n", argv[i] ); error_exit();