µTasker Forum

µTasker Forum => µTasker general => Topic started by: alager on April 12, 2010, 06:36:08 PM

Title: DNS bug when using the final '.' notation
Post by: alager on April 12, 2010, 06:36:08 PM
Mark,

In fnResolveHostName() if the cHostNamePtr ends with a '.' eg. "www.google.com."  Then the string parsing fails, and DNS is left in the BUSY state, without ever having sent a UPD packet, nor triggering the timer to allow the task to complete or fail.

Below is my simple, but code bloated way of fixing it.  If you have a more elegant method, that would be welcomed.
Code: [Select]
if ((*cHostNamePtr) == '.') {                                    // still not at the end, skip dot
            cHostNamePtr++;
if ((*cHostNamePtr) == '\0') {                               // add ZERO, QTYPE and QCLASS
                uMemcpy(ucBuf, ucZeroQTypeClass, sizeof(ucZeroQTypeClass));
                uTaskerMonoTimer( OWN_TASK, DNS_RESEND_PERIOD, E_DNS_RESEND ); // monitor resolution
                                                                         // send the request
                fnSendUDP(DNSSocketNr, ucDNS_server_temp_ip, DNS_UDP_PORT, (unsigned char *)&UDP_Message.tUDP_Header, (unsigned short)(usTotal + 13 + sizeof(ucZeroQTypeClass)), TASK_DNS);
            }
        }
        else {
            if ((*cHostNamePtr) == '\0') {                               // add ZERO, QTYPE and QCLASS
                uMemcpy(ucBuf, ucZeroQTypeClass, sizeof(ucZeroQTypeClass));
                uTaskerMonoTimer( OWN_TASK, DNS_RESEND_PERIOD, E_DNS_RESEND ); // monitor resolution
                                                                         // send the request
                fnSendUDP(DNSSocketNr, ucDNS_server_temp_ip, DNS_UDP_PORT, (unsigned char *)&UDP_Message.tUDP_Header, (unsigned short)(usTotal + 13 + sizeof(ucZeroQTypeClass)), TASK_DNS);
            }
        }

Aaron
Title: Re: DNS bug when using the final '.' notation
Post by: mark on April 12, 2010, 08:30:41 PM
Hi Aaron

Is a URL with dot at the end legal?
I am wondering whether it is not better to ensure that no URLs are saved with a dot at the end by parsing them beforehand and deleting it if necessary. The same would also be true for URLs entered at run time, by correcting the end if necessary - note that a fully qualified address will end with '/' - (eg www.google.com/ ) here I hope (but am not sure) that it will be accepted normally.

What do you think?

Regards

Mark
Title: Re: DNS bug when using the final '.' notation
Post by: alager on April 12, 2010, 09:12:12 PM
I was looking for the RFC, that talks about this specifically, but the end dot is indeed legal.  It means, don't try to append anything to this while looking it up.  It allows for people to do a local look up, without having to enter the fully qualified domain name.  eg. "server1", instead of "server1.utasker.com", but of course, then what to do with someone who does enter the full domain name?  Well just add another dot, eg "server1.utasker.com." and the system won't append to it.
I think it's probably old and antiquated, but our new programmer formerly from Cisco told me about it while we were trying to figure out why our device (using utasker) wouldn't resolve DNS on a customers network.  When we tried it, it hosed the thing.

Aaron
Title: Re: DNS bug when using the final '.' notation
Post by: mark on April 12, 2010, 10:56:17 PM
Hi Aaron

One learns something new every day ;-)
If this is allowed it seems logical that it should also work.
I will do some study and get back if I find an improved solution to the one that you implemented.

Regards

Mark