Get rid of SERVERQUIT code in ssl_{client,server}2

This commit is contained in:
Manuel Pégourié-Gonnard 2014-08-14 17:47:17 +02:00
parent 74b11702d7
commit dcab293bd4
2 changed files with 13 additions and 26 deletions

View file

@ -322,7 +322,7 @@ static int my_verify( void *data, x509_crt *crt, int depth, int *flags )
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
int ret = 0, len, server_fd, i, written, frags; int ret = 0, len, tail_len, server_fd, i, written, frags;
unsigned char buf[SSL_MAX_CONTENT_LEN + 1]; unsigned char buf[SSL_MAX_CONTENT_LEN + 1];
#if defined(POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED) #if defined(POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED)
unsigned char psk[POLARSSL_PSK_MAX_LEN]; unsigned char psk[POLARSSL_PSK_MAX_LEN];
@ -1055,18 +1055,13 @@ send_request:
printf( " > Write to server:" ); printf( " > Write to server:" );
fflush( stdout ); fflush( stdout );
if( strcmp( opt.request_page, "SERVERQUIT" ) == 0 )
len = sprintf( (char *) buf, "%s", opt.request_page );
else
{
size_t tail_len = strlen( GET_REQUEST_END );
len = snprintf( (char *) buf, sizeof(buf) - 1, GET_REQUEST, len = snprintf( (char *) buf, sizeof(buf) - 1, GET_REQUEST,
opt.request_page ); opt.request_page );
tail_len = strlen( GET_REQUEST_END );
/* Add padding to GET request to reach opt.request_size in length */ /* Add padding to GET request to reach opt.request_size in length */
if( opt.request_size != DFL_REQUEST_SIZE && if( opt.request_size != DFL_REQUEST_SIZE &&
len + tail_len < (size_t) opt.request_size ) len + tail_len < opt.request_size )
{ {
memset( buf + len, 'A', opt.request_size - len - tail_len ); memset( buf + len, 'A', opt.request_size - len - tail_len );
len += opt.request_size - len - tail_len; len += opt.request_size - len - tail_len;
@ -1074,7 +1069,6 @@ send_request:
strncpy( (char *) buf + len, GET_REQUEST_END, sizeof(buf) - len - 1 ); strncpy( (char *) buf + len, GET_REQUEST_END, sizeof(buf) - len - 1 );
len += tail_len; len += tail_len;
}
/* Truncate if request size is smaller than the "natural" size */ /* Truncate if request size is smaller than the "natural" size */
if( opt.request_size != DFL_REQUEST_SIZE && if( opt.request_size != DFL_REQUEST_SIZE &&

View file

@ -1559,13 +1559,6 @@ reset:
polarssl_free( larger_buf ); polarssl_free( larger_buf );
} }
if( memcmp( buf, "SERVERQUIT", 10 ) == 0 )
{
ret = 0;
goto exit;
}
if( ret > 0 ) if( ret > 0 )
break; break;
} }