[PATCH] res_query() silently rejects responses against T_ANY DNS questions.

Natanael Copa natanael.copa at gmail.com
Mon Mar 4 14:49:24 UTC 2013


looks similar to this issue:
http://git.alpinelinux.org/cgit/aports/plain/main/libc0.9.32/0002-resolv-res_query-for-CNAMEs.patch

Sent to the list 2009:
http://lists.busybox.net/pipermail/uclibc/2009-June/042583.html



On Mon, Jul 9, 2012 at 3:01 AM, Chris Luke <chrisy at flirble.org> wrote:

> res_query() is rejecting T_ANY and T_CNAME requests since they give
> answers with a different type. It also doesn't reject them cleanly,
> returning the length of the packet that would be returned (but not filling
> in the buffer) instead of -1.
>
> This commit fixes that by allowing T_ANY questions to have any type of
> answer and T_A or T_AAAA questions to have T_CNAME answers.
>
> It also returns -1 if it otherwise rejects the response.
>
> See https://bugs.busybox.net/show_**bug.cgi?id=5342<https://bugs.busybox.net/show_bug.cgi?id=5342>which has a test case for this.
>
> Patch has been tested on OpenWrt and i386 buildroot.
>
> Signed-off-by: Chris Luke <chrisy at flirble.org>
> ---
>  libc/inet/resolv.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
> index e9f550b..06af2dc 100644
> --- a/libc/inet/resolv.c
> +++ b/libc/inet/resolv.c
> @@ -3736,10 +3736,16 @@ int res_query(const char *dname, int class, int
> type,
>          free(a.dotted);
>  -       if (a.atype == type) { /* CNAME */
> +       /* Copy the answer only if the type asked for is the same as the
> answer,
> +        * we asked for T_ANY, or an A or AAAA returned a CNAME first.
> +        */
> +       if (a.atype == type || type == T_ANY || (a.atype == T_CNAME &&
> (type == T_A || type == T_AAAA))) {
>                 if (i > anslen)
>                         i = anslen;
>                 memcpy(answer, packet, i);
> +       } else {
> +               h_errno = NO_DATA;
> +               i = -1;
>         }
>         free(packet);
>         return i;
> --
> 1.7.9.5
>
>
> ______________________________**_________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/**mailman/listinfo/uclibc<http://lists.busybox.net/mailman/listinfo/uclibc>
>



-- 
Natanael Copa


More information about the uClibc mailing list