Skip to content

Commit

Permalink
programs/ssl: Fixes incorrect EOF check in ssl_context_info.c
Browse files Browse the repository at this point in the history
read_next_b64_code() function, that parses base64 encoded input
doesn't recognize the EOF and returns when "Too many bad symbols
are detected". This issue got identified when gcc complained for
type-limit error during cmake.

This patch fixes the issue by changing the variable type to int
and removing type-cast of fgetc() output to 'char'.

Signed-off-by: Nayna Jain <[email protected]>
  • Loading branch information
naynajain committed Aug 14, 2020
1 parent ee7e85f commit 89cf0f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.d/bugfix_type_limit_warning_ssl_context_info.txt
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions programs/ssl/ssl_context_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down

0 comments on commit 89cf0f3

Please sign in to comment.