On Sun, 23 Apr 2017 00:18:07 +0200
Hiltjo Posthuma <[email protected]> wrote:
> On Sat, Apr 22, 2017 at 08:14:06AM +0900, YASUOKA Masahiko wrote:
>> On Fri, 21 Apr 2017 13:52:51 +0900 (JST)
>> YASUOKA Masahiko <[email protected]> wrote:
>> > +int
>> > +pfctl_parse_host(char *str, struct pf_rule_addr *addr)
>> > +{
>> (snip)
>> > + if ((sbs = strchr(s, '[')) != NULL || (sbe = strrchr(s, ']')) != NULL) {
>> > + hints.ai_family = AF_INET6;
>> > + *(sbs++) = *sbe = '\0';
>>
>> The condition must be
>>
>> if ((sbs = strchr(s, '[')) != NULL && (sbe = strrchr(s, ']')) != NULL) {
>>
>> I will fix this before commit.
>
> Hey,
>
> Shouldn't it be:
>
> if ((sbs = strchr(s, '[')) != NULL && (sbe = strrchr(sbs, ']')) !=
> NULL) {
> ^
>
> Since the ] should come after [ ?
Yes, it's better. Thanks.
ok?
Index: sbin/pfctl/pfctl.c
===================================================================
RCS file: /cvs/src/sbin/pfctl/pfctl.c,v
retrieving revision 1.340
diff -u -p -r1.340 pfctl.c
--- sbin/pfctl/pfctl.c 21 Apr 2017 23:22:49 -0000 1.340
+++ sbin/pfctl/pfctl.c 23 Apr 2017 09:02:20 -0000
@@ -762,7 +762,8 @@ pfctl_parse_host(char *str, struct pf_ru
hints.ai_socktype = SOCK_DGRAM; /* dummy */
hints.ai_flags = AI_NUMERICHOST;
- if ((sbs = strchr(s, '[')) != NULL && (sbe = strrchr(s, ']')) != NULL) {
+ if ((sbs = strchr(s, '[')) != NULL &&
+ (sbe = strrchr(sbs, ']')) != NULL) {
hints.ai_family = AF_INET6;
*(sbs++) = *sbe = '\0';
} else if ((sbs = strchr(s, ':')) != NULL) {