BUG/MINOR: tools: fix url2sa return value with IPv4
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 24 Mar 2022 20:59:03 +0000 (21:59 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 25 Mar 2022 12:57:50 +0000 (13:57 +0100)
Fix 8a91374 ("BUG/MINOR: tools: url2sa reads ipv4 too far") introduced a
regression in the value returned when parsing an ipv4 host.

Tthe consumed length is supposed to be as far as the first character of
the path, only its not computed correctly anymore and return the length
minus the size of the scheme.

Fixed the issue by reverting 'curr' and 'url' as they were before the
patch.

Must be backported in every stable branch where the 8a91374 patch was
backported.

(cherry picked from commit b938b77ade7b75bff94f810eec78e7e065f04f81)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit a83367a2c2de5c267f1c199f3295c27c8dc794c6)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>
(cherry picked from commit 086323a2010dd095f623f49f689d81d47052e1a7)
Signed-off-by: William Lallemand <wlallemand@haproxy.org>

src/tools.c

index 61c5bf5..e0fcf2b 100644 (file)
@@ -1541,9 +1541,7 @@ int url2sa(const char *url, int ulen, struct sockaddr_storage *addr, struct spli
                                out->host_len = ret;
                        }
 
-                       /* we need to assign again curr and end from the trash */
-                       url = trash.area;
-                       curr = trash.area + ret;
+                       curr += ret;
 
                        /* Decode port. */
                        if (*curr == ':') {