1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Merge pull request #1347 from mpg/fix-asn1-store-named-data-null-deref-3.6

Backport 3.6: Fix asn1 store named data null deref
This commit is contained in:
Manuel Pégourié-Gonnard
2025-06-10 09:50:34 +02:00
committed by GitHub
5 changed files with 47 additions and 1 deletions

View File

@ -90,7 +90,9 @@ int mbedtls_asn1_write_raw_buffer(unsigned char **p, const unsigned char *start,
len = size;
(*p) -= len;
memcpy(*p, buf, len);
if (len != 0) {
memcpy(*p, buf, len);
}
return (int) len;
}
@ -412,6 +414,7 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data(
} else if (val_len == 0) {
mbedtls_free(cur->val.p);
cur->val.p = NULL;
cur->val.len = 0;
} else if (cur->val.len != val_len) {
/*
* Enlarge existing value buffer if needed