mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	Revise how output allocation is checked
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
		@@ -7429,10 +7429,7 @@ psa_status_t psa_raw_key_agreement(psa_algorithm_t alg,
 | 
				
			|||||||
                                            output_length);
 | 
					                                            output_length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exit:
 | 
					exit:
 | 
				
			||||||
    /* Check for successful allocation of output. */
 | 
					    if (output != NULL && status != PSA_SUCCESS) {
 | 
				
			||||||
    if (output != NULL && status != PSA_ERROR_INSUFFICIENT_MEMORY) {
 | 
					 | 
				
			||||||
        /* output allocated. */
 | 
					 | 
				
			||||||
        if (status != PSA_SUCCESS) {
 | 
					 | 
				
			||||||
        /* If an error happens and is not handled properly, the output
 | 
					        /* If an error happens and is not handled properly, the output
 | 
				
			||||||
        * may be used as a key to protect sensitive data. Arrange for such
 | 
					        * may be used as a key to protect sensitive data. Arrange for such
 | 
				
			||||||
        * a key to be random, which is likely to result in decryption or
 | 
					        * a key to be random, which is likely to result in decryption or
 | 
				
			||||||
@@ -7442,7 +7439,6 @@ exit:
 | 
				
			|||||||
        */
 | 
					        */
 | 
				
			||||||
        psa_generate_random(output, output_size);
 | 
					        psa_generate_random(output, output_size);
 | 
				
			||||||
        *output_length = output_size;
 | 
					        *output_length = output_size;
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* output allocation failed. */
 | 
					        /* output allocation failed. */
 | 
				
			||||||
        *output_length = 0;
 | 
					        *output_length = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user