]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: httpclient/cli: free of unallocated hc->req.uri
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 10 Nov 2021 15:57:25 +0000 (16:57 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 10 Nov 2021 16:02:50 +0000 (17:02 +0100)
httpclient_new() sets the hc->req.uri ist without duplicating its
memory, which is a problem since the string in the ist could be
inaccessible at some point. The API was made to use a ist which was
allocated dynamically, but httpclient_new() didn't do that, which result
in a crash when calling istfree().

This patch fixes the problem by doing an istdup()

Fix issue #1452.

src/http_client.c

index fe85f050b80489f2e75cb0d9609955090d427f22..4e5ef7c1c7fbb6ff30019771631a38e34b174d8c 100644 (file)
@@ -535,7 +535,7 @@ struct httpclient *httpclient_new(void *caller, enum http_meth_t meth, struct is
                goto err;
 
        hc->caller = caller;
-       hc->req.url = url;
+       hc->req.url = istdup(url);
        hc->req.meth = meth;
 
        return hc;