Fix potential overflow.

In practice, it never may happen.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2024-06-22 19:03:37 +02:00
parent 2700163e1f
commit 447c68febd
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3

View file

@ -42,7 +42,7 @@ uint16_t asn1_len(asn1_ctx_t *ctx) {
uint32_t asn1_get_uint(asn1_ctx_t *ctx) {
uint32_t d = ctx->data[0];
for (uint8_t lt = 1; lt < ctx->len; lt++) {
for (uint8_t lt = 1; lt < MIN(ctx->len, sizeof(uint32_t)); lt++) {
d <<= 8;
d |= ctx->data[lt];
}