mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-05 18:55:41 +00:00
Allow requests of size larger than 16384 in ssl_client2
This commit is contained in:
parent
5175ac6e13
commit
e4ad3e8803
|
@ -63,6 +63,9 @@ int main( void )
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define MAX_REQUEST_SIZE 20000
|
||||||
|
#define MAX_REQUEST_SIZE_STR "20000"
|
||||||
|
|
||||||
#define DFL_SERVER_NAME "localhost"
|
#define DFL_SERVER_NAME "localhost"
|
||||||
#define DFL_SERVER_ADDR NULL
|
#define DFL_SERVER_ADDR NULL
|
||||||
#define DFL_SERVER_PORT "4433"
|
#define DFL_SERVER_PORT "4433"
|
||||||
|
@ -243,7 +246,7 @@ int main( void )
|
||||||
" server_port=%%d default: 4433\n" \
|
" server_port=%%d default: 4433\n" \
|
||||||
" request_page=%%s default: \".\"\n" \
|
" request_page=%%s default: \".\"\n" \
|
||||||
" request_size=%%d default: about 34 (basic request)\n" \
|
" request_size=%%d default: about 34 (basic request)\n" \
|
||||||
" (minimum: 0, max: 16384)\n" \
|
" (minimum: 0, max: " MAX_REQUEST_SIZE_STR " )\n" \
|
||||||
" debug_level=%%d default: 0 (disabled)\n" \
|
" debug_level=%%d default: 0 (disabled)\n" \
|
||||||
" nbio=%%d default: 0 (blocking I/O)\n" \
|
" nbio=%%d default: 0 (blocking I/O)\n" \
|
||||||
" options: 1 (non-blocking), 2 (added delays)\n" \
|
" options: 1 (non-blocking), 2 (added delays)\n" \
|
||||||
|
@ -437,7 +440,9 @@ int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int ret = 0, len, tail_len, i, written, frags, retry_left;
|
int ret = 0, len, tail_len, i, written, frags, retry_left;
|
||||||
mbedtls_net_context server_fd;
|
mbedtls_net_context server_fd;
|
||||||
unsigned char buf[MBEDTLS_SSL_MAX_CONTENT_LEN + 1];
|
|
||||||
|
unsigned char buf[MAX_REQUEST_SIZE + 1];
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
|
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
|
||||||
unsigned char psk[MBEDTLS_PSK_MAX_LEN];
|
unsigned char psk[MBEDTLS_PSK_MAX_LEN];
|
||||||
size_t psk_len = 0;
|
size_t psk_len = 0;
|
||||||
|
@ -602,7 +607,8 @@ int main( int argc, char *argv[] )
|
||||||
else if( strcmp( p, "request_size" ) == 0 )
|
else if( strcmp( p, "request_size" ) == 0 )
|
||||||
{
|
{
|
||||||
opt.request_size = atoi( q );
|
opt.request_size = atoi( q );
|
||||||
if( opt.request_size < 0 || opt.request_size > MBEDTLS_SSL_MAX_CONTENT_LEN )
|
if( opt.request_size < 0 ||
|
||||||
|
opt.request_size > MAX_REQUEST_SIZE )
|
||||||
goto usage;
|
goto usage;
|
||||||
}
|
}
|
||||||
else if( strcmp( p, "ca_file" ) == 0 )
|
else if( strcmp( p, "ca_file" ) == 0 )
|
||||||
|
@ -1550,6 +1556,12 @@ send_request:
|
||||||
|
|
||||||
frags = 1;
|
frags = 1;
|
||||||
written = ret;
|
written = ret;
|
||||||
|
|
||||||
|
if( written < len )
|
||||||
|
{
|
||||||
|
mbedtls_printf( " warning\n ! request didn't fit into single datagram and "
|
||||||
|
"was truncated to size %u", (unsigned) written );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[written] = '\0';
|
buf[written] = '\0';
|
||||||
|
|
Loading…
Reference in a new issue