ssl_mail_client.c: silence warning, check base64_encode() status
Found with Clang's `scan-build` tool. ssl_mail_client.c does a dead store by assigning the return value of base64_encode() to `len` and not using the value. This causes scan-build to issue a warning. Instead of storing the return value into `len`, store it to `ret`, since base64_encode() returns a status code, not a length. Also check if the return value is nonzero and print an error; this silences scan-build.
This commit is contained in:
parent
5b78f219d0
commit
7c03424d1c
@ -719,8 +719,13 @@ int main( int argc, char *argv[] )
|
||||
fflush( stdout );
|
||||
|
||||
n = sizeof( buf );
|
||||
len = base64_encode( base, &n, (const unsigned char *) opt.user_name,
|
||||
ret = base64_encode( base, &n, (const unsigned char *) opt.user_name,
|
||||
strlen( opt.user_name ) );
|
||||
|
||||
if( ret != 0 ) {
|
||||
printf( " failed\n ! base64_encode returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
len = sprintf( (char *) buf, "%s\r\n", base );
|
||||
ret = write_ssl_and_get_response( &ssl, buf, len );
|
||||
if( ret < 300 || ret > 399 )
|
||||
@ -734,8 +739,13 @@ int main( int argc, char *argv[] )
|
||||
printf( " > Write password to server: %s", opt.user_pwd );
|
||||
fflush( stdout );
|
||||
|
||||
len = base64_encode( base, &n, (const unsigned char *) opt.user_pwd,
|
||||
ret = base64_encode( base, &n, (const unsigned char *) opt.user_pwd,
|
||||
strlen( opt.user_pwd ) );
|
||||
|
||||
if( ret != 0 ) {
|
||||
printf( " failed\n ! base64_encode returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
len = sprintf( (char *) buf, "%s\r\n", base );
|
||||
ret = write_ssl_and_get_response( &ssl, buf, len );
|
||||
if( ret < 200 || ret > 399 )
|
||||
|
Loading…
Reference in New Issue
Block a user