mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 09:55:46 +01:00
Adjusted buf allocated from heap in ssl_client2 to be as small as possible
This commit is contained in:
parent
614efc268e
commit
7800719551
@ -1522,9 +1522,23 @@ int main( int argc, char *argv[] )
|
|||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_buf_len = MAX_REQUEST_SIZE + 1;
|
/* try to use as small buf from the heap as possible */
|
||||||
buf = mbedtls_calloc( 1, MAX_REQUEST_SIZE + 1 );
|
if( opt.request_size <= 0 )
|
||||||
if( buf == NULL ) {
|
{
|
||||||
|
main_buf_len = MBEDTLS_SSL_MAX_CONTENT_LEN + 1;
|
||||||
|
}
|
||||||
|
else if( opt.request_size < (int)sizeof(GET_REQUEST) )
|
||||||
|
{
|
||||||
|
main_buf_len = sizeof(GET_REQUEST) + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
main_buf_len = opt.request_size + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = mbedtls_calloc( 1, main_buf_len );
|
||||||
|
if( buf == NULL )
|
||||||
|
{
|
||||||
mbedtls_printf( "buf allocation failed!\n" );
|
mbedtls_printf( "buf allocation failed!\n" );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user