aws/aws-encryption-sdk-c

Use safe memset in derive_key_v2

Closed this issue · 0 comments

In aws_cryptosdk_private_derive_key_v2 we write:

memset(commitment->buffer, 0, props->commitment_len);

with the intention that props->commitment_len may be zero, in which case commitment->buffer is not writable, but this is OK since the memset would be a no-op. The C standard says that even in this case the pointer argument commitment->buffer must be valid. We should change this so that memset is not called with an invalid pointer argument.