]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: acme: fix false positive null pointer dereference
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 Sep 2025 08:34:35 +0000 (10:34 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 Sep 2025 08:34:35 +0000 (10:34 +0200)
src/acme.c: In function ‘cfg_parse_acme_vars_provider’:
src/acme.c:471:9: error: potential null pointer dereference [-Werror=null-dereference]
  471 |         free(*dst);
      |         ^~~~~~~~~~

gcc13 on ubuntu 24.04 detects a false positive when building
3e72a9f ("MINOR: acme: provider-name for dpapi sink").
Indeed dst can't be NULL. Clarify the code so gcc don't complain
anymore.

src/acme.c

index dcd26c8cd20a8af33bae7f10df824074891e352d..4249638ca0f6ae43e63c88c2be6fc4c2889f8cfb 100644 (file)
@@ -466,9 +466,14 @@ static int cfg_parse_acme_vars_provider(char **args, int section_type, struct pr
                dst = &cur_acme->vars;
        } else if (strcmp(args[0], "provider-name") == 0) {
                dst = &cur_acme->provider;
+       } else {
+               err_code |= ERR_ALERT | ERR_FATAL;
+               ha_alert("parsing [%s:%d]: unsupported keyword '%s'.\n", file, linenum, args[0]);
+               goto out;
        }
 
-       free(*dst);
+       if (dst)
+               free(*dst);
 
        if (!*args[1]) {
                ha_alert("parsing [%s:%d]: keyword '%s' in '%s' section requires an argument\n", file, linenum, args[0], cursection);