g10: Fix out-of-bounds read.

* g10/armor.c (use_armor_filter): We need two bytes for 'is_armored'.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-07-05 12:38:15 +02:00
parent 8c8ae043b8
commit a6b87981f7
1 changed files with 4 additions and 2 deletions

View File

@ -274,15 +274,17 @@ is_armored( const byte *buf )
int
use_armor_filter( IOBUF a )
{
byte buf[1];
byte buf[2];
int n;
/* fixme: there might be a problem with iobuf_peek */
n = iobuf_peek(a, buf, 1 );
n = iobuf_peek (a, buf, 2);
if( n == -1 )
return 0; /* EOF, doesn't matter whether armored or not */
if( !n )
return 1; /* can't check it: try armored */
if (n != 2)
return 0; /* short buffer */
return is_armored(buf);
}