]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: http-htx: Silent build error about a possible NULL start-line
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Nov 2022 17:02:00 +0000 (18:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 22 Nov 2022 17:02:02 +0000 (18:02 +0100)
In http_replace_req_uri(), if the URI was successfully replaced, it means
the start-line exists. However, the compiler reports an error about a
possible NULL pointer dereference:

src/http_htx.c: In function ‘http_replace_req_uri’:
src/http_htx.c:392:19: error: potential null pointer dereference [-Werror=null-dereference]
  392 |         sl->flags &= ~HTX_SL_F_NORMALIZED_URI;

So, ALREADY_CHECKED() macro is used to silent the build error. This patch
must be backported with 84cdbe478a ("BUG/MINOR: http-htx: Don't consider an
URI as normalized after a set-uri action").

src/http_htx.c

index 3dfbd010624feba44e9ca8e89dfef32afd5291dd..7cfaca4a4d0feff4c2d11cd85f976320f01b3f86 100644 (file)
@@ -389,6 +389,8 @@ int http_replace_req_uri(struct htx *htx, const struct ist uri)
                goto fail;
 
        sl = http_get_stline(htx);
+       ALREADY_CHECKED(sl); /* the stline exists because http_replace_stline() succeded */
+
        sl->flags &= ~HTX_SL_F_NORMALIZED_URI;
        if (!http_update_host(htx, sl, uri))
                goto fail;