mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-29 02:33:37 -04:00 
			
		
		
		
	Misc review requested fixes
Style fixes and cast certain defines to size_t Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
		
							parent
							
								
									21c62a2aed
								
							
						
					
					
						commit
						3891caf1ce
					
				| @ -2304,7 +2304,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "%s session has been resumed", | ||||
|                    ssl->handshake->resume ? "a" : "no" ) ); | ||||
| 
 | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %04x", (unsigned int)i ) ); | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %04x", (unsigned) i ) ); | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: %d", | ||||
|                                 buf[37 + n] ) ); | ||||
| 
 | ||||
|  | ||||
| @ -623,9 +623,9 @@ int mbedtls_ssl_encrypt_buf( mbedtls_ssl_context *ssl, | ||||
| 
 | ||||
|     if( rec->data_len > MBEDTLS_SSL_OUT_CONTENT_LEN ) | ||||
|     { | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record content %u too large, maximum %d", | ||||
|                                     (unsigned) rec->data_len, | ||||
|                                     MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record content %zu too large, maximum %zu", | ||||
|                                     rec->data_len, | ||||
|                                     (size_t) MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|         return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); | ||||
|     } | ||||
| 
 | ||||
| @ -2699,9 +2699,9 @@ int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) | ||||
|     if( ssl->out_msglen > MBEDTLS_SSL_OUT_CONTENT_LEN ) | ||||
|     { | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record too large: " | ||||
|                                     "size %u, maximum %u", | ||||
|                                     (unsigned) ssl->out_msglen, | ||||
|                                     (unsigned) MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|                                     "size %zu, maximum %zu", | ||||
|                                     ssl->out_msglen, | ||||
|                                     (size_t) MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|         return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); | ||||
|     } | ||||
| 
 | ||||
| @ -2728,9 +2728,9 @@ int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) | ||||
|             if( MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen < 8 ) | ||||
|             { | ||||
|                 MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS handshake message too large: " | ||||
|                               "size %u, maximum %u", | ||||
|                                (unsigned) ( hs_len ), | ||||
|                                (unsigned) ( MBEDTLS_SSL_OUT_CONTENT_LEN - 12 ) ) ); | ||||
|                               "size %zu, maximum %zu", | ||||
|                                hs_len, | ||||
|                                (size_t) ( MBEDTLS_SSL_OUT_CONTENT_LEN - 12 ) ) ); | ||||
|                 return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); | ||||
|             } | ||||
| 
 | ||||
| @ -4325,24 +4325,24 @@ static int ssl_buffer_message( mbedtls_ssl_context *ssl ) | ||||
|                     { | ||||
|                         /* If we can't buffer a future message because
 | ||||
|                          * of space limitations -- ignore. */ | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %zu would exceed the compile-time limit %d (already %zu bytes buffered) -- ignore\n", | ||||
|                              msg_len, MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %zu would exceed the compile-time limit %zu (already %zu bytes buffered) -- ignore\n", | ||||
|                              msg_len, (size_t) MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                              hs->buffering.total_bytes_buffered ) ); | ||||
|                         goto exit; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %zu would exceed the compile-time limit %d (already %zu bytes buffered) -- attempt to make space by freeing buffered future messages\n", | ||||
|                              msg_len, MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %zu would exceed the compile-time limit %zu (already %zu bytes buffered) -- attempt to make space by freeing buffered future messages\n", | ||||
|                              msg_len, (size_t) MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                              hs->buffering.total_bytes_buffered ) ); | ||||
|                     } | ||||
| 
 | ||||
|                     if( ssl_buffer_make_space( ssl, reassembly_buf_sz ) != 0 ) | ||||
|                     { | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Reassembly of next message of size %zu (%zu with bitmap) would exceed the compile-time limit %d (already %zu bytes buffered) -- fail\n", | ||||
|                         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Reassembly of next message of size %zu (%zu with bitmap) would exceed the compile-time limit %zu (already %zu bytes buffered) -- fail\n", | ||||
|                              msg_len, | ||||
|                              reassembly_buf_sz, | ||||
|                              MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                              (size_t) MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                              hs->buffering.total_bytes_buffered ) ); | ||||
|                         ret = MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL; | ||||
|                         goto exit; | ||||
| @ -4622,8 +4622,8 @@ static int ssl_buffer_future_record( mbedtls_ssl_context *ssl, | ||||
|     if( rec->buf_len > ( MBEDTLS_SSL_DTLS_MAX_BUFFERING - | ||||
|                          hs->buffering.total_bytes_buffered ) ) | ||||
|     { | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future epoch record of size %zu would exceed the compile-time limit %d (already %zu bytes buffered) -- ignore\n", | ||||
|                         rec->buf_len, MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future epoch record of size %zu would exceed the compile-time limit %zu (already %zu bytes buffered) -- ignore\n", | ||||
|                         rec->buf_len, (size_t) MBEDTLS_SSL_DTLS_MAX_BUFFERING, | ||||
|                         hs->buffering.total_bytes_buffered ) ); | ||||
|         return( 0 ); | ||||
|     } | ||||
|  | ||||
| @ -299,12 +299,12 @@ static int ssl_parse_signature_algorithms_ext( mbedtls_ssl_context *ssl, | ||||
|             mbedtls_ssl_sig_hash_set_add( &ssl->handshake->hash_algs, sig_cur, md_cur ); | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext:" | ||||
|                                         " match sig %u and hash %u", | ||||
|                                         sig_cur, md_cur ) ); | ||||
|                                         (unsigned) sig_cur, (unsigned) md_cur ) ); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: " | ||||
|                                         "hash alg %u not supported", md_cur ) ); | ||||
|                                         "hash alg %u not supported", (unsigned) md_cur ) ); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -1048,7 +1048,7 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, | ||||
|     } | ||||
| 
 | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "trying ciphersuite: %#04x (%s)", | ||||
|                                 (unsigned int)suite_id, suite_info->name ) ); | ||||
|                                 (unsigned int) suite_id, suite_info->name ) ); | ||||
| 
 | ||||
|     if( suite_info->min_minor_ver > ssl->minor_ver || | ||||
|         suite_info->max_minor_ver < ssl->minor_ver ) | ||||
| @ -1116,7 +1116,7 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, | ||||
|             mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, sig_type ) == MBEDTLS_MD_NONE ) | ||||
|         { | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: no suitable hash algorithm " | ||||
|                                         "for signature algorithm %u", sig_type ) ); | ||||
|                                         "for signature algorithm %u", (unsigned) sig_type ) ); | ||||
|             return( 0 ); | ||||
|         } | ||||
|     } | ||||
| @ -2274,7 +2274,7 @@ have_ciphersuite: | ||||
|         else | ||||
|         { | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 3, ( "no hash algorithm for signature algorithm " | ||||
|                                         "%u - should not happen", sig_alg ) ); | ||||
|                                         "%u - should not happen", (unsigned) sig_alg ) ); | ||||
|         } | ||||
|     } | ||||
| #endif | ||||
| @ -2926,7 +2926,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", | ||||
|            mbedtls_ssl_get_ciphersuite_name( ssl->session_negotiate->ciphersuite ) ) ); | ||||
|     MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, compress alg.: 0x%02X", | ||||
|                    (unsigned int)ssl->session_negotiate->compression ) ); | ||||
|                    (unsigned int) ssl->session_negotiate->compression ) ); | ||||
| 
 | ||||
|     /* Do not write the extensions if the protocol is SSLv3 */ | ||||
| #if defined(MBEDTLS_SSL_PROTO_SSL3) | ||||
| @ -3502,7 +3502,7 @@ curve_matching_done: | ||||
|             md_alg = MBEDTLS_MD_NONE; | ||||
|         } | ||||
| 
 | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 3, ( "pick hash algorithm %u for signing", md_alg ) ); | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 3, ( "pick hash algorithm %u for signing", (unsigned) md_alg ) ); | ||||
| 
 | ||||
|         /*
 | ||||
|          * 2.2: Compute the hash to be signed | ||||
|  | ||||
| @ -970,7 +970,7 @@ static int ssl_populate_transform( mbedtls_ssl_transform *transform, | ||||
|     if( md_info == NULL ) | ||||
|     { | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 1, ( "mbedtls_md info for %u not found", | ||||
|                             ciphersuite_info->mac ) ); | ||||
|                             (unsigned) ciphersuite_info->mac ) ); | ||||
|         return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); | ||||
|     } | ||||
| 
 | ||||
| @ -2215,8 +2215,8 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) | ||||
|         n = crt->raw.len; | ||||
|         if( n > MBEDTLS_SSL_OUT_CONTENT_LEN - 3 - i ) | ||||
|         { | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate too large, %zu > %d", | ||||
|                            i + 3 + n, MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|             MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate too large, %zu > %zu", | ||||
|                            i + 3 + n, (size_t) MBEDTLS_SSL_OUT_CONTENT_LEN ) ); | ||||
|             return( MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE ); | ||||
|         } | ||||
| 
 | ||||
| @ -2707,7 +2707,7 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl, | ||||
| #if defined(MBEDTLS_DEBUG_C) | ||||
|     if( ssl->session_negotiate->verify_result != 0 ) | ||||
|     { | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %x", | ||||
|         MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %08x", | ||||
|                                     (unsigned int) ssl->session_negotiate->verify_result ) ); | ||||
|     } | ||||
|     else | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Paul Elliott
						Paul Elliott