busybox dnsd to support domainname search
Denys Vlasenko
vda.linux at googlemail.com
Sun Apr 12 03:35:39 UTC 2009
On Saturday 11 April 2009 12:13, Ming-Ching Tiew wrote:
>
> I have tested this with busybox 1.13.3 :-
Note that _I_ did not test it, as I am personally don't need it :)
It means that you probably know more about it than me.
I can attest that code does not look too good. Just look at this:
struct dns_head *head;
struct dns_prop *qprop;
uint8_t *from, *answb;
...
head = (struct dns_head *)buf;
if (head->flags & 0x8000) {
bb_error_msg("ignoring response packet");
return -1;
}
from = (void *)&head[1]; // start of query string
//FIXME: strlen of untrusted data??!
^^^^^^^^ first bug
querystr_len = strlen((char *)from) + 1 + sizeof(struct dns_prop);
answb = from + querystr_len; // where to append answer block
outr_rlen = 0;
outr_flags = 0;
qprop = (struct dns_prop *)(answb - 4);
^^ not a bug, but why author can't initialize this _first_,
and then make answb = (void)(qprop + 1)?
also, - 4 is the size of struct dns_prop, but why author
did not use sizeof? Also #2, qprop may end up unaligned,
and code below does not account for that!
...
/* we only support standard queries */
if ((ntohs(head->flags) & 0x7800) != 0)...
But above we checked head->flags _without_ htons!
These both can't be right, one of them is a bug.
With your feeadback and help I can make it better.
> the busybox dnsd does not support a fqdn search because of two reasons :-
>
> 1. The MAX_HOST_LEN is too short.
>
> A typical fqdn is much longer than the default in the C file.
Please bump it up and let me know the result.
> 2. I am not the dns expert, but when a fqdn get delivered into dnsd,
>
> www.xxx.yyy becomes www control-G xxxx control-C yyyy
>
> ie the first dot becomes char 7, and second dot becomes char 3.
>
> This limitation can be workaround by entering the ^G ^C into dnsd.conf.
>
> These are just minor fixes which could be done to allow dnsd to support fqdn search from standard clients.
I tried to implement your suggestion #2 in the attached file.
It compiles, but I did not run test it. Can you do it?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dnsd.c
Type: text/x-csrc
Size: 17528 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090412/6eec8f9e/attachment-0001.c>
More information about the busybox
mailing list