Commit 8a0c0a9e authored by Paul Bakker's avatar Paul Bakker
Browse files

Check additional return values in some test cases

parent 94b916c7
......@@ -146,7 +146,12 @@ int main( int argc, char *argv[] )
printf( " failed\n ! fopen returned NULL\n" );
goto exit;
}
fgets( buf, sizeof(buf), f );
if( fgets( buf, sizeof(buf), f ) == NULL )
{
fclose( f );
printf( "Error: fgets() failed to retrieve password\n" );
goto exit;
}
fclose( f );
i = (int) strlen( buf );
......
......@@ -101,6 +101,7 @@ void mpi_read_file( int radix_X, char *input_file, char *input_A,
mpi_init( &X );
file = fopen( input_file, "r" );
TEST_ASSERT( file != NULL );
TEST_ASSERT( mpi_read_file( &X, radix_X, file ) == result );
fclose(file);
......
......@@ -17,6 +17,7 @@ void pk_write_pubkey_check( char *key_file )
unsigned char check_buf[5000];
int ret;
FILE *f;
size_t ilen;
memset( buf, 0, sizeof( buf ) );
memset( check_buf, 0, sizeof( check_buf ) );
......@@ -29,9 +30,10 @@ void pk_write_pubkey_check( char *key_file )
f = fopen( key_file, "r" );
TEST_ASSERT( f != NULL );
fread( check_buf, 1, sizeof( check_buf ) - 1, f );
ilen = fread( check_buf, 1, sizeof( check_buf ) - 1, f );
fclose( f );
TEST_ASSERT( ilen == strlen( (char *) buf ) );
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
pk_free( &key );
......@@ -46,6 +48,7 @@ void pk_write_key_check( char *key_file )
unsigned char check_buf[5000];
int ret;
FILE *f;
size_t ilen;
memset( buf, 0, sizeof( buf ) );
memset( check_buf, 0, sizeof( check_buf ) );
......@@ -58,9 +61,10 @@ void pk_write_key_check( char *key_file )
f = fopen( key_file, "r" );
TEST_ASSERT( f != NULL );
fread( check_buf, 1, sizeof( check_buf ) - 1, f );
ilen = fread( check_buf, 1, sizeof( check_buf ) - 1, f );
fclose( f );
TEST_ASSERT( ilen == strlen( (char *) buf ) );
TEST_ASSERT( strncmp( (char *) buf, (char *) check_buf, sizeof( buf ) ) == 0 );
pk_free( &key );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment