]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
def_load: avoid NULL deref
authorSerge Hallyn <serge@hallyn.com>
Fri, 19 May 2023 19:49:04 +0000 (14:49 -0500)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 22 May 2023 08:23:12 +0000 (10:23 +0200)
If econf_getStringValue() fails, it will return an error and
set value to NULL.  Look for the error and avoid dereferencing
value in that case.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
lib/getdef.c

index 39cd62d5132566d933a5c5fb97cf5394a13fa9a0..8075821b0bfb39209d27430f25e7eb5c3fdb85c9 100644 (file)
@@ -505,7 +505,12 @@ static void def_load (void)
        for (size_t i = 0; i < key_number; i++) {
                char *value;
 
-               econf_getStringValue(defs_file, NULL, keys[i], &value);
+               error = econf_getStringValue(defs_file, NULL, keys[i], &value);
+               if (error) {
+                       SYSLOG ((LOG_CRIT, "failed reading key %zu from econf [%s]",
+                               i, econf_errString(error)));
+                       exit (EXIT_FAILURE);
+               }
 
                /*
                 * Store the value in def_table.