>> Hi,
>>
>> I wonder why the code send the TCP port in the DNS query...
>> I'm currently installing an opnsense and I'll try to reproduce the
>> problem.
>>
>> I've not used FreeBSD since 5.4 version :)
>>
>> Baptiste
>
> Hi Baptiste,
>
> it seems ipv4 and ipv6 are handled differently regarding the removal of the
> port in server.c and this is apparently done after the initial dns check has
> already been performed.?. as it knows to treat 'google.com' differently from
> 'nu.nl'
>
>             /* save hostname and create associated name resolution */
>             switch (sk->ss_family) {
>             case AF_INET: {
>                 /* remove the port if any */
> Alert("\n AF_INET remove the port if any: %s", args[2]);
>                 char *c;
>                 if ((c = rindex(args[2], ':')) != NULL) {
>                     newsrv->hostname = my_strndup(args[2], c - args[2]);
>                 }
>                 else {
>                     newsrv->hostname = strdup(args[2]);
>                 }
>             }
>                 break;
>             case AF_INET6:
> Alert("\n AF_INET6   args 2              : %s", args[2]);
>                 newsrv->hostname = strdup(args[2]);
>                 break;
>             default:
>                 goto skip_name_resolution;
>             }
> Alert("\nparse_server newsrv->hostname: %s", newsrv->hostname);
>
> Result:
>  AF_INET6   args 2              : www.google.com:80[ALERT] 249/231349
> (38431) :
> parse_server newsrv->hostname: www.google.com:80[ALERT] 249/231349 (38431) :
>  AF_INET remove the port if any: nu.nl:80[ALERT] 249/231349 (38431) :
> parse_server newsrv->hostname: nu.nl[ALERT] 249/231349 (38431) :
>
> Though the tricky part i guess is that ipv6 can contain ':' in a address to
> but not in a hostname i would think.. Maybe the question should be why have
> the different treatment at all?
>
> I would expect this to not occur on FreeBSD systems.?
>
> Hope it helps investigate the issue.
>
> PiBa-NL


Hi Piba,

You're right and I think this bug is not linked to FreeBSD at all :)
I think checking port1 and port2 variables at this moment of the code
is the best way to go instead of relying on ss_family.
I'll send you a patch later today for testing purpose.

Baptiste

Reply via email to