commit | 694d3aeb47872d35e3e652bf6f39117a83f28246 | [log] [tgz] |
---|---|---|
author | Paul Bakker <p.j.bakker@polarssl.org> | Mon Aug 19 14:23:38 2013 +0200 |
committer | Paul Bakker <p.j.bakker@polarssl.org> | Mon Aug 19 14:23:38 2013 +0200 |
tree | 7cd5bd9ee333dfc13475e8b862893b863332adfe | |
parent | 04784f57e45ef4d83674e75248b3f260cd112fcd [diff] |
Fixed potential heap buffer overflow on large file reading
diff --git a/library/x509parse.c b/library/x509parse.c index a4ee6b5..535b180 100644 --- a/library/x509parse.c +++ b/library/x509parse.c
@@ -1925,7 +1925,8 @@ *n = (size_t) ftell( f ); fseek( f, 0, SEEK_SET ); - if( ( *buf = (unsigned char *) polarssl_malloc( *n + 1 ) ) == NULL ) + if( *n + 1 == 0 || + ( *buf = (unsigned char *) polarssl_malloc( *n + 1 ) ) == NULL ) { fclose( f ); return( POLARSSL_ERR_X509_MALLOC_FAILED );