eriptic / uoscore-uedhoc

C implementations for constrained (and non-constrained) devices of the IETF protocols OSCORE and EDHOC
Other
16 stars 16 forks source link

Add pointers validation before memcpy operation #10

Closed AleksanderDemianowski closed 2 years ago

AleksanderDemianowski commented 2 years ago

memcpy function shouldn't be run on NULL pointers. Added validation crashes tests because test vectors includes sender_id or id_context set to NULL. If tests vectors force us to handle NULL pointers of these arguments we can:

  1. Return ok after check and do not perform memcpy, set dest pointer to NULL and exit with ok exit code. I don't like to return ok if the operation can be done properly (NULL pointers)
  2. Use special TRY_MEMCPY macro to validate the result with proper handling of wrong_parameter error code.

@StefanHri what do you think?