From 447c68febd3f5586790d7c6155d02bf244814b4e Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sat, 22 Jun 2024 19:03:37 +0200 Subject: [PATCH] Fix potential overflow. In practice, it never may happen. Signed-off-by: Pol Henarejos --- src/asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asn1.c b/src/asn1.c index 9a8f42a..41c25ba 100644 --- a/src/asn1.c +++ b/src/asn1.c @@ -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]; }