programs/ssl: Fix incorrect EOF check in ssl_context_info.c

In `read_next_b64_code()`, the result of fgetc() is stored into a char,
but later compared against EOF, which is generally -1.  On platforms
where char is unsigned, this generates a compiler warning/error that the
comparison will never be true (causing a build failure).  The value will
never match, with the function ultimately bailing with a "Too many bad
symbols are detected" error.

On platforms with signed char, EOF is detected, but a file containing a
0xFF character will causes a premature end of file exit of the loop.

Fix this by changing the result to an int.

Fixes #3794.

Signed-off-by: Nayna Jain <[email protected]>
Signed-off-by: David Brown <[email protected]>
This commit is contained in:
Nayna Jain
2020-10-20 13:31:32 -06:00
committed by David Brown
parent 8f24a8bb34
commit d696e7d91e
2 changed files with 6 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
Bugfix
* Fix handling of EOF against 0xff bytes and on platforms with
unsigned chars. Fixes a build failure on platforms where char is
unsigned. Fixes #3794.
+2 -2
View File
@@ -377,13 +377,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 )
{