diff --git a/ChangeLog.d/bugfix_type_limit_warning_ssl_context_info.txt b/ChangeLog.d/bugfix_type_limit_warning_ssl_context_info.txt new file mode 100644 index 000000000000..5a9d2623ba74 --- /dev/null +++ b/ChangeLog.d/bugfix_type_limit_warning_ssl_context_info.txt @@ -0,0 +1,3 @@ +Bugfix + * read_next_b64_code() isn't correctly checking against EOF because it checks against 'char' rather than 'int'. This is identified via type-limit warning reported by gcc. + Reported and fix contributed by naynajain in #3449. diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c index 9bea31c69024..fb870c86bd7f 100644 --- a/programs/ssl/ssl_context_info.c +++ b/programs/ssl/ssl_context_info.c @@ -379,13 +379,13 @@ size_t read_next_b64_code( uint8_t **b64, size_t *max_len ) int valid_balance = 0; /* balance between valid and invalid characters */ size_t len = 0; char pad = 0; - char c = 0; + int c = 0; while( EOF != c ) { char c_valid = 0; - c = (char) fgetc( b64_file ); + c = fgetc( b64_file ); if( pad > 0 ) { diff --git a/tests/context-info.sh b/tests/context-info.sh index 344dd4ea93d0..742e2db1e8aa 100755 --- a/tests/context-info.sh +++ b/tests/context-info.sh @@ -400,7 +400,12 @@ run_test "Wrong base64 format" \ "def_bad_b64.txt" \ -m "ERROR" \ -u "The length of the base64 code found should be a multiple of 4" \ - -n "bytes left to analyze from context" + -n "bytes left to analyze from context" \ + +run_test "EOF base64 format" \ + "def_bad_b64_eof.txt" \ + -m "Finished. No valid base64 code found" \ + -n "ERROR" \ run_test "Too much data at the beginning of base64 code" \ "def_b64_too_big_1.txt" \ diff --git a/tests/data_files/base64/def_bad_b64_eof.txt b/tests/data_files/base64/def_bad_b64_eof.txt new file mode 100644 index 000000000000..59593b0534f4 --- /dev/null +++ b/tests/data_files/base64/def_bad_b64_eof.txt @@ -0,0 +1 @@ +/w==