From: Valentine Krasnobaeva Date: Fri, 9 Aug 2024 07:25:37 +0000 (+0200) Subject: BUG/MINOR: cfgparse: parse_cfg: fix null ptr dereference reported by coverity X-Git-Tag: v3.1-dev6~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16e89f6b5c77d054868e83b9d202630d105f77fc;p=thirdparty%2Fhaproxy.git BUG/MINOR: cfgparse: parse_cfg: fix null ptr dereference reported by coverity This commit fixes potential null ptr dereferences reported by coverity, see more details about it in the issues #2676 and #2668. 'outline' ptr, which is initialized to NULL explicitly as a temporary buffer to store split keywords may be in theory implicitly dereferenced in some corner cases (which we haven't encountered yet with real world configurations) in 'if (!**args)'. parse_line() code, called before under some conditions assigns: args[arg] = outline + outpos and outpos initial value is 0. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index bf43b02fd1..09b5b3a845 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2293,7 +2293,7 @@ next_line: /* end of config dump */ /* empty line */ - if (!**args) + if (!*args || !**args) continue; /* check for config macros */