[Skiboot] [PATCH] nvram: Fix a possible NULL pointer de-ref in nvram_query_eq()

Vaibhav Jain vaibhav at linux.ibm.com
Sat Sep 8 16:51:22 AEST 2018


A fault will occur if 'value == NULL' is passed to nvram_query_eq() to
check if a given key doesn't exists in nvram partition. This patch
fixes this issue by ensuring that a NULL value for argument 'value'
never reaches the call to strcmp().

Signed-off-by: Vaibhav Jain <vaibhav at linux.ibm.com>
---
 core/nvram-format.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/nvram-format.c b/core/nvram-format.c
index 42c5cbbb..c52b443a 100644
--- a/core/nvram-format.c
+++ b/core/nvram-format.c
@@ -282,8 +282,8 @@ bool nvram_query_eq(const char *key, const char *value)
 {
 	const char *s = nvram_query(key);
 
-	if (!s)
-		return false;
+	if (s == NULL || value == NULL)
+		return s == value;
 
 	return !strcmp(s, value);
 }
-- 
2.17.1



More information about the Skiboot mailing list