From 79ff634f7eb873360de0d78d4beaaa054052b10a Mon Sep 17 00:00:00 2001 From: Mimi Zohar Date: Wed, 30 Jun 2021 16:07:34 -0400 Subject: [PATCH] Fix NULL pointer warning Static analysis reported an "invalid operation involving NULL pointer" warning. Although the code properly exits the loop without ever using the variable, test the pointer isn't NULL before incrementing it. Fixes: 80d3fda6083f ("ima-evm-utils: Check for tsspcrread in runtime") Reviewed-by: Lakshmi Ramasubramanian Signed-off-by: Mimi Zohar --- src/utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index fbb6a4b..294dac5 100644 --- a/src/utils.c +++ b/src/utils.c @@ -77,7 +77,8 @@ int get_cmd_path(const char *prog_name, char *buf, size_t buf_len) if (buf_len - size > ret && file_exist(buf)) return 0; - start = end + 1; + if (end != NULL) + start = end + 1; } while (end != NULL);