mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	Compare buffers even for zero-length cases
This enables us to test that lengths are correctly zero when the buffer pointer is NULL. Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
		@@ -98,9 +98,9 @@ void input_copy_alloc(int input_len, psa_status_t exp_status)
 | 
				
			|||||||
            TEST_ASSERT(input_copy.buffer == NULL);
 | 
					            TEST_ASSERT(input_copy.buffer == NULL);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            TEST_ASSERT(input_copy.buffer != input);
 | 
					            TEST_ASSERT(input_copy.buffer != input);
 | 
				
			||||||
            TEST_MEMORY_COMPARE(input, input_len,
 | 
					 | 
				
			||||||
                                input_copy.buffer, input_copy.len);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        TEST_MEMORY_COMPARE(input, input_len,
 | 
				
			||||||
 | 
					                            input_copy.buffer, input_copy.len);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exit:
 | 
					exit:
 | 
				
			||||||
@@ -169,9 +169,8 @@ void output_copy_alloc(int output_len, psa_status_t exp_status)
 | 
				
			|||||||
        TEST_ASSERT(output_copy.original == output);
 | 
					        TEST_ASSERT(output_copy.original == output);
 | 
				
			||||||
        if (output == NULL) {
 | 
					        if (output == NULL) {
 | 
				
			||||||
            TEST_ASSERT(output_copy.buffer == NULL);
 | 
					            TEST_ASSERT(output_copy.buffer == NULL);
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            TEST_EQUAL(output_copy.len, output_len);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        TEST_EQUAL(output_copy.len, output_len);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exit:
 | 
					exit:
 | 
				
			||||||
@@ -215,10 +214,8 @@ void output_copy_free(int output_len, int original_is_null,
 | 
				
			|||||||
    if (exp_status == PSA_SUCCESS) {
 | 
					    if (exp_status == PSA_SUCCESS) {
 | 
				
			||||||
        TEST_ASSERT(output_copy.buffer == NULL);
 | 
					        TEST_ASSERT(output_copy.buffer == NULL);
 | 
				
			||||||
        TEST_EQUAL(output_copy.len, 0);
 | 
					        TEST_EQUAL(output_copy.len, 0);
 | 
				
			||||||
        if (output != NULL) {
 | 
					        TEST_MEMORY_COMPARE(buffer_copy_for_comparison, output_len,
 | 
				
			||||||
            TEST_MEMORY_COMPARE(buffer_copy_for_comparison, output_len,
 | 
					                            output, output_len);
 | 
				
			||||||
                                output, output_len);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exit:
 | 
					exit:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user