mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-30 11:11:12 -04:00 
			
		
		
		
	Fix GCC warning in ssl_calc_finished_tls_sha384
				
					
				
			This commit fixes the same warning fixed by baeedbf9, but without wasting RAM. By casting `mbedtls_sha512_finish_ret()`, `padbuf` could be kept 48 bytes long without triggering any warnings. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
This commit is contained in:
		
							parent
							
								
									683028a2f7
								
							
						
					
					
						commit
						d596ca8a1e
					
				| @ -3197,12 +3197,15 @@ static void ssl_calc_finished_tls_sha256( | ||||
| #endif /* MBEDTLS_SHA256_C */ | ||||
| 
 | ||||
| #if defined(MBEDTLS_SHA512_C) | ||||
| 
 | ||||
| typedef int (*finish_sha384_t)(mbedtls_sha512_context*, unsigned char[48]); | ||||
| 
 | ||||
| static void ssl_calc_finished_tls_sha384( | ||||
|                 mbedtls_ssl_context *ssl, unsigned char *buf, int from ) | ||||
| { | ||||
|     int len = 12; | ||||
|     const char *sender; | ||||
|     unsigned char padbuf[64]; | ||||
|     unsigned char padbuf[48]; | ||||
| #if defined(MBEDTLS_USE_PSA_CRYPTO) | ||||
|     size_t hash_size; | ||||
|     psa_hash_operation_t sha384_psa = PSA_HASH_OPERATION_INIT; | ||||
| @ -3255,8 +3258,14 @@ static void ssl_calc_finished_tls_sha384( | ||||
|     MBEDTLS_SSL_DEBUG_BUF( 4, "finished sha512 state", (unsigned char *) | ||||
|                    sha512.state, sizeof( sha512.state ) ); | ||||
| #endif | ||||
|     /*
 | ||||
|      * For SHA-384, we can save 16 bytes by keeping padbuf 48 bytes long. | ||||
|      * However, to avoid stringop-overflow warning in gcc, we have to cast | ||||
|      * mbedtls_sha512_finish_ret(). | ||||
|      */ | ||||
|     finish_sha384_t finish = (finish_sha384_t)mbedtls_sha512_finish_ret; | ||||
|     finish( &sha512, padbuf ); | ||||
| 
 | ||||
|     mbedtls_sha512_finish_ret( &sha512, padbuf ); | ||||
|     mbedtls_sha512_free( &sha512 ); | ||||
| #endif | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Rodrigo Dias Correa
						Rodrigo Dias Correa