udhcpd host name issue

Denys Vlasenko vda.linux at googlemail.com
Tue Apr 21 08:23:13 UTC 2009


On Tuesday 21 April 2009 09:03, Mahavir Jain wrote:
> On Tue, Apr 21, 2009 at 6:07 AM, Denys Vlasenko
> <vda.linux at googlemail.com> wrote:
> >> In   networking/udhcp/leases.c
> >>
> >> -  hostname = (uint8_t*) safe_strncpy((char*)oldest->hostname,
> >> (char*)hostname, hostname_length );
> >> +  hostname = (uint8_t*) safe_strncpy((char*)oldest->hostname,
> >> (char*)hostname, hostname_length + 1);
> >>
> >> As safe_strncpy makes string to truncate last character to null, it
> >> makes host name not to display last character.
> >
> > Can you show the problematic output of dumpleases?
> > --
> 
> Yes Sure.
> 
> Wireshark log on client side:-
> 
> Bootstrap Protocol
> 1	0.000000	192.168.1.100	255.255.255.255	DHCP	DHCP Request  -
> Transaction ID 0x8f6113b7
> 
> Bootp flags: 0x0000 (Unicast)
> Option: (t=53,l=1) DHCP Message Type = DHCP Request
> Option: (t=61,l=7) Client identifier
> Option: (t=12,l=8) Host Name = "pe-lt231"
> 
> 
> At shell :
> 
> $ dumpleases -f /var/lib/udhcpd.leases
> Mac Address       IP Address      Host Name           Expires in
> 00:1c:25:91:3b:2a 192.168.1.100   pe-lt23             00:15:45

Thanks, I fixed it like this:

                        hostname_length = hostname[-1] + 1;   <=====
                        if (hostname_length > sizeof(oldest->hostname))
                                hostname_length = sizeof(oldest->hostname);
                        hostname = (uint8_t*) safe_strncpy((char*)oldest->hostname, (char*)hostname, hostname_length);

--
vda


More information about the busybox mailing list