Skip to content

Commit

Permalink
Allow null buffers when the length is 0
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Peskine <[email protected]>
  • Loading branch information
gilles-peskine-arm committed Feb 26, 2024
1 parent 84dc44b commit 9721b86
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ int mbedtls_ecp_point_read_binary(const mbedtls_ecp_group *grp,
size_t plen;
ECP_VALIDATE_RET(grp != NULL);
ECP_VALIDATE_RET(pt != NULL);
ECP_VALIDATE_RET(buf != NULL);
ECP_VALIDATE_RET(ilen == 0 || buf != NULL);

if (ilen < 1) {
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
Expand Down Expand Up @@ -996,7 +996,7 @@ int mbedtls_ecp_tls_read_point(const mbedtls_ecp_group *grp,
ECP_VALIDATE_RET(grp != NULL);
ECP_VALIDATE_RET(pt != NULL);
ECP_VALIDATE_RET(buf != NULL);
ECP_VALIDATE_RET(*buf != NULL);
ECP_VALIDATE_RET(buf_len == 0 || *buf != NULL);

/*
* We must have at least two bytes (1 for length, at least one for data)
Expand Down Expand Up @@ -1068,7 +1068,7 @@ int mbedtls_ecp_tls_read_group(mbedtls_ecp_group *grp,
mbedtls_ecp_group_id grp_id;
ECP_VALIDATE_RET(grp != NULL);
ECP_VALIDATE_RET(buf != NULL);
ECP_VALIDATE_RET(*buf != NULL);
ECP_VALIDATE_RET(len == 0 || *buf != NULL);

if ((ret = mbedtls_ecp_tls_read_group_id(&grp_id, buf, len)) != 0) {
return ret;
Expand All @@ -1088,7 +1088,7 @@ int mbedtls_ecp_tls_read_group_id(mbedtls_ecp_group_id *grp,
const mbedtls_ecp_curve_info *curve_info;
ECP_VALIDATE_RET(grp != NULL);
ECP_VALIDATE_RET(buf != NULL);
ECP_VALIDATE_RET(*buf != NULL);
ECP_VALIDATE_RET(len == 0 || *buf != NULL);

/*
* We expect at least three bytes (see below)
Expand Down Expand Up @@ -3361,7 +3361,7 @@ int mbedtls_ecp_write_key(mbedtls_ecp_keypair *key,
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;

ECP_VALIDATE_RET(key != NULL);
ECP_VALIDATE_RET(buf != NULL);
ECP_VALIDATE_RET(buflen == 0 || buf != NULL);

#if defined(MBEDTLS_ECP_MONTGOMERY_ENABLED)
if (mbedtls_ecp_get_type(&key->grp) == MBEDTLS_ECP_TYPE_MONTGOMERY) {
Expand Down

0 comments on commit 9721b86

Please sign in to comment.