Преглед на файлове

lib/parse_ini.c - check inifile before access

Added check to verifiy inifile was not null post fopen(). Should be caught by other checks though.
Spenser Reinhardt преди 11 години
родител
ревизия
53d14c718a
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      lib/parse_ini.c

+ 4 - 1
lib/parse_ini.c

@@ -141,12 +141,15 @@ np_arg_list* np_get_defaults(const char *locator, const char *default_section){
                                 die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file."), strerror(errno));
                 }
 
+		/* before attempting access, let's make sure inifile is not null, this should never be the case though */
+		if (inifile == NULL)
+			die(STATE_UNKNOWN, "%s %s\n", _("Can't read config file:"), strerror(errno));
                 /* inifile points to an open FILE our ruid/rgid can access, parse its contents. */
                 if (read_defaults(inifile, i.stanza, &defaults) == FALSE)
                         die(STATE_UNKNOWN,"%s%s%s%s'\n", _("Invalid section '"), i.stanza, _("' in config file '"), i.file);
 
                 if (inifile != stdin) fclose(inifile);
-        }
+        } 
 
 	if (i.file != NULL) {
 		free(i.file);