[uClibc]Lily says there is a bug in uClibc of gethostbyname()

Marshall M. Midden m4 at brecis.com
Thu Sep 12 03:08:59 UTC 2002


The version of uclibc that the problem is reported on is 0.9.12.
The current one I am using/looking at is from Sept 6th, 2002 snapshot.

Edited message ...
> From: Lily at amit2 [mailto:lily at email.amit.com.tw]
> Sent: Monday, September 09, 2002 7:16 PM
> Subject: bug in uClibc of gethostbyname()
> 
> file: uClinux/uclibc/libc/inet/resolv.c
> function: dns_lookup()
> line:587    the prototype of id should be (short), not (int)
>         original:        id = (int) random();
>                 change to:    id = (short) random();
>  
>                or it will be an error(hid !=  id) on line:674
>                if ((h.id != id) || (!h.qr))
>                     /* unsolicited */
>                     goto again;
>  
> FYI.
>                     ....Lily

------------------------------------------------------------------------------
September 6th's resolv.c has a slight change:

610:	int __dns_lookup(const char *name, int type, int nscount, char **nsip,
...
716:	                if ((h.id != id) || (!h.qr)) {
...

972:	int res_init(void)
...
980:	        rp->id = (u_int) random();

------------------------------------------------------------------------------
I think he is right.

214:	int __decode_header(unsigned char *data, struct resolv_header *h)
	{
	        h->id = (data[0] << 8) | data[1];

Can't be anymore than 16 bits.  A "mips" that we are using has "short" as 16
bits.

I thought that the right fix (for all architectures) was:
	 id = (u_int) random() & 0xffff;

My boss looked at the code and said -- isn't there a missing htons there?
I don't see any of those things in the code.  My confusion continues.
And I am stoppping work on this, too much else to do.



More information about the uClibc mailing list