From 304dcae89581af5c65b68a03566d9c1cc72fa804 Mon Sep 17 00:00:00 2001 From: Adam Wujek <adam.wujek@cern.ch> Date: Tue, 1 Nov 2016 15:17:26 +0100 Subject: [PATCH] userspace/snmpd: don't crash when number of kernel modules greater than expected Signed-off-by: Adam Wujek <adam.wujek@cern.ch> --- userspace/snmpd/wrsBootStatusGroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/userspace/snmpd/wrsBootStatusGroup.c b/userspace/snmpd/wrsBootStatusGroup.c index b14b54b15..e570843f8 100644 --- a/userspace/snmpd/wrsBootStatusGroup.c +++ b/userspace/snmpd/wrsBootStatusGroup.c @@ -427,7 +427,8 @@ static void get_loaded_kernel_modules_status(void) continue; /* error... or EOF */ /* try educated guess to find position in array */ - if (!strncmp(key, kernel_modules[guess_index].key, 40)) { + if (guess_index < ARRAY_SIZE(kernel_modules) + && !strncmp(key, kernel_modules[guess_index].key, 40)) { modules_found++; guess_index++; continue; -- GitLab