1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

g10/armor: fix eof checks in radix64_read

* g10/armor.c (radix64_read): Check EOF with '!afx->buffer_len' instead
of 'c == -1', as 'c' is never set to this value.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
This commit is contained in:
Jussi Kivilinna 2018-11-08 21:31:12 +02:00
parent 5d6c080522
commit a571bb8df5

View File

@ -793,7 +793,7 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
byte *buf, size_t size ) byte *buf, size_t size )
{ {
byte val; byte val;
int c=0, c2; /*init c because gcc is not clever enough for the continue*/ int c, c2;
int checkcrc=0; int checkcrc=0;
int rc = 0; int rc = 0;
size_t n = 0; size_t n = 0;
@ -911,7 +911,7 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
continue; continue;
break; break;
} }
if( c == -1 ) if( !afx->buffer_len )
log_error(_("premature eof (no CRC)\n")); log_error(_("premature eof (no CRC)\n"));
else { else {
u32 mycrc = 0; u32 mycrc = 0;
@ -945,7 +945,7 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
if( !afx->buffer_len ) if( !afx->buffer_len )
break; /* eof */ break; /* eof */
} while( ++idx < 4 ); } while( ++idx < 4 );
if( c == -1 ) { if( !afx->buffer_len ) {
log_info(_("premature eof (in CRC)\n")); log_info(_("premature eof (in CRC)\n"));
rc = invalid_crc(); rc = invalid_crc();
} }