udhcpd host name issue

Denys Vlasenko vda.linux at googlemail.com
Wed Apr 1 09:57:32 UTC 2009


On Monday 30 March 2009 07:50, Mahavir Jain wrote:
> Hello,
> 
> I have dhcp server configured in busybox 1.13.3. , but for me it is
> very difficult identify clients based on
> 
> dumpleases -f udhcpd.lease file . This file gives me idea of connected
> clients with mac address & assigned lease.
> 
> But i could see that it is very easy to get host name of client in
> bootp protocol with DHCP_HOST_NAME macro in busybox.
> Following patch (attached) does trick for me , which gives me good
> idea about clients.

# patch -p1 </tmp/review.patch
patching file networking/udhcp/dhcpd.h
Hunk #1 FAILED at 79.
1 out of 1 hunk FAILED -- saving rejects to file networking/udhcp/dhcpd.h.rej
patching file networking/udhcp/dumpleases.c
Hunk #1 FAILED at 36.
Hunk #2 FAILED at 45.
2 out of 2 hunks FAILED -- saving rejects to file networking/udhcp/dumpleases.c.rej
patching file networking/udhcp/files.c
Hunk #1 FAILED at 401.
1 out of 1 hunk FAILED -- saving rejects to file networking/udhcp/files.c.rej
patching file networking/udhcp/leases.c
Hunk #1 FAILED at 43.
Hunk #2 succeeded at 59 with fuzz 1 (offset 5 lines).
1 out of 3 hunks FAILED -- saving rejects to file networking/udhcp/leases.c.rej
patching file networking/udhcp/serverpacket.c
Hunk #1 FAILED at 104.
Hunk #2 succeeded at 146 (offset -3 lines).
Hunk #3 succeeded at 207 with fuzz 2 (offset -1 lines).
Hunk #4 FAILED at 239.
2 out of 4 hunks FAILED -- saving rejects to file networking/udhcp/serverpacket.c.rej


-       printf("Mac Address       IP-Address      Expires %s\n", (opt & OPT_a) ? "at" : "in");
-       /*     "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */
+       printf("Mac Address       IP-Address      Host Name                     Expires %s\n", (opt & OPT_a) ? "at" : "in");
+       /*     "00:00:00:00:00:00 255.255.255.255 AAAAAAAAAAAAAAAAAAAAAAA       Wed Jun 30 21:49:08 1993" */

This will overflow 80 columns


+               if (host_name) 
+               {
+                       hostname_length = *(host_name - 1);
+                       memcpy(oldest->hostname, host_name, hostname_length);
+               }
+               else
+               {
+                       oldest->hostname[0] = '\0';
+               }

and if hostname_length happens to become > 30, memcpy will corrupt memory
past the end of the oldest->hostname.


                printf(" %-15s ", inet_ntoa(addr));
+               printf(" %-30s ", lease.hostname);

Can be combined into one printf.


> As previously suggested by vda  that dumpleases -a option is broken &
> following patch is needed.
> Why yet this is not included in busybox stable 1.13.3. ...?

Because it is not a regression. It was broken for a long time.
Code in 1.14.x deals with this problem properly.
--
vda


More information about the busybox mailing list