]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: tools: fix bad character handling in str2sa_range()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Mar 2013 14:28:17 +0000 (15:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Mar 2013 18:08:26 +0000 (19:08 +0100)
Commit d4448bc8 brought support for parsing port ranges, but invalid
characters are not properly handled and can result in a crash while
parsing the configuration if an invalid character is present in the
port, because the return value is set to NULL then dereferenced.

src/standard.c

index db0e0e409085f5e450cf07c68f18ceac21274769..be6b91190ff5932d697eff2a572f0fc6600b9664 100644 (file)
@@ -679,8 +679,10 @@ struct sockaddr_storage *str2sa_range(const char *str, int *low, int *high)
                porth = atoi(port1 + 1);
                porta = porth;
        }
-       else if (*port1) /* other any unexpected char */
+       else if (*port1) /* other any unexpected char */
                ret = NULL;
+               goto out;
+       }
 
        set_host_port(ret, porta);