From b2c53dc67a6a509f6e6d7f6ba540c55bbc34e988 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 22 Nov 2021 01:19:05 +0000 Subject: [PATCH] command-nas: fix out-of-bounds read Limit iteration to number of array members fixing potential out-of-bounds read. Coverity CID: 1493471 Out-of-bounds read Signed-off-by: Daniel Golle --- commands-nas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands-nas.c b/commands-nas.c index 123ba63..01ca3b8 100644 --- a/commands-nas.c +++ b/commands-nas.c @@ -83,7 +83,7 @@ print_earfcn_info(uint32_t earfcn) { 45590, 46589, 44, 700, "TDD" }, }; - for (int i = 0; i < sizeof(earfcn_ranges); i++) { + for (int i = 0; i < (sizeof(earfcn_ranges) / sizeof(*earfcn_ranges)); i++) { if (earfcn <= earfcn_ranges[i].max && earfcn >= earfcn_ranges[i].min) { blobmsg_add_u32(&status, "band", earfcn_ranges[i].band); blobmsg_add_u32(&status, "frequency", earfcn_ranges[i].freq); -- 2.30.2