On Tue, Oct 13, 2015 at 08:10:03PM +0200, Mildis wrote:
>
> Le 2015-10-10 15:49, Willy Tarreau a écrit :
> >Hi,
>
> >@@ -856,11 +883,28 @@ struct sockaddr_storage *str2sa_range(const char
> >*str, int *low, int *high, char
> > else { /* IPv4 and IPv6 */
> > int use_fqdn = 0;
> >
> >- port1 = strrchr(str2, ':');
> >- if (port1)
> >- *port1++ = '\0';
> >- else
> >+ /* IPv6 wildcard */
> >+ if (!strcmp(str2, "::")) {
> >+ port1 = "";
> >+ }
> >
> >You're changing the parser here, because it now accepts "::" in a place
> >where a port was expected.
>
> May I ask : isn???t the parser just a parser ? Making the caller???s
> responsibility to use or not the ports returned either in the
> sockaddr_storage or the 2 int depending on the context ? (???bind???
> requires a port but ???server??????s port is optional)
> Is str2sa_range aware of the context it???s called ?
str2sa_range() parses ports, it relies on str2ip2() which only takes
addresses. So according to this it *is* the caller. Your change above
broke this because you're making the former ignore its own responsibility
to properly consider the port which is mandatory if the address contains
a colon. And that's precisely because str2sa_range() doesn't have to be
aware of the context it's called that we want it to behave consistently.
Regards,
Willy