cfgfile: fix null pointer dereference in parsing
Function memchr() could return NULL and assign it to split[1] pointer.
Additional check and error handing is made after memchr() call.
Coverity issue: 195004
Fixes: a6a47ac9c2
("cfgfile: rework load function")
Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
This commit is contained in:
parent
dc3c853ce2
commit
74e0d3a174
@ -241,6 +241,11 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
|
||||
|
||||
split[0] = buffer;
|
||||
split[1] = memchr(buffer, '=', len);
|
||||
if (split[1] == NULL) {
|
||||
printf("Error line %d - no '='"
|
||||
"character found\n", lineno);
|
||||
goto error1;
|
||||
}
|
||||
*split[1] = '\0';
|
||||
split[1]++;
|
||||
|
||||
@ -268,7 +273,7 @@ rte_cfgfile_load_with_params(const char *filename, int flags,
|
||||
goto error1;
|
||||
|
||||
_add_entry(&cfg->sections[cfg->num_sections - 1],
|
||||
split[0], (split[1] ? split[1] : ""));
|
||||
split[0], split[1]);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
|
Loading…
Reference in New Issue
Block a user