View | Details | Raw Unified | Return to bug 128605
Collapse All | Expand All

(-)./dhclient.c (-3 / +29 lines)
Lines 629-641 Link Here
629
{
629
{
630
	struct interface_info *ip = packet->interface;
630
	struct interface_info *ip = packet->interface;
631
	struct client_lease *lease;
631
	struct client_lease *lease;
632
	struct in_addr addr;
632
633
633
	/* If we're not receptive to an offer right now, or if the offer
634
	/* If we're not receptive to an offer right now, or if the offer
634
	   has an unrecognizable transaction id, then just drop it. */
635
	   has an unrecognizable transaction id, then just drop it. */
635
	if (packet->interface->client->xid != packet->raw->xid ||
636
	if (packet->interface->client->xid != packet->raw->xid ||
636
	    (packet->interface->hw_address.hlen != packet->raw->hlen) ||
637
	    (packet->interface->hw_address.hlen != packet->raw->hlen) ||
637
	    (memcmp(packet->interface->hw_address.haddr,
638
	    (memcmp(packet->interface->hw_address.haddr,
638
	    packet->raw->chaddr, packet->raw->hlen)))
639
	    packet->raw->chaddr, packet->raw->hlen))
640
	   )
639
		return;
641
		return;
640
642
641
	if (ip->client->state != S_REBOOTING &&
643
	if (ip->client->state != S_REBOOTING &&
Lines 654-659 Link Here
654
656
655
	ip->client->new = lease;
657
	ip->client->new = lease;
656
658
659
	/* 
660
	 * October 30 2008 - Raffaele De Lorenzo (raffaele.delorenzo@libero.it)
661
	 * Security check - Check if the DHCP server identifier (ip address) match 
662
	 * with localhost (127.0.0.0/8). RFC 2131 required a valid server identifier 
663
	 * ip address.
664
	 *
665
	 */
666
	bzero (&addr, sizeof (struct in_addr));
667
	if (inet_aton (piaddr(packet->client_addr), &addr) != 1){
668
		fprintf (stderr, "ERROR - dhcpack - Server address unreadable\n");
669
		return;
670
	}
671
	/* apply mask at address */
672
	addr.s_addr &= 0x000000FF;
673
	if (addr.s_addr == 0x00007F){
674
		fprintf (stderr, "ERROR - dhcpack - Server ID [%s] not valid (localhost)\n",
675
			 piaddr(packet->client_addr));
676
		return;
677
	}
678
657
	/* Stop resending DHCPREQUEST. */
679
	/* Stop resending DHCPREQUEST. */
658
	cancel_timeout(send_request, ip);
680
	cancel_timeout(send_request, ip);
659
681
Lines 838-849 Link Here
838
	    "DHCPOFFER" : "BOOTREPLY";
860
	    "DHCPOFFER" : "BOOTREPLY";
839
861
840
	/* If we're not receptive to an offer right now, or if the offer
862
	/* If we're not receptive to an offer right now, or if the offer
841
	   has an unrecognizable transaction id, then just drop it. */
863
	   has an unrecognizable transaction id, then just drop it. 
864
	*/
865
	
866
842
	if (ip->client->state != S_SELECTING ||
867
	if (ip->client->state != S_SELECTING ||
843
	    packet->interface->client->xid != packet->raw->xid ||
868
	    packet->interface->client->xid != packet->raw->xid ||
844
	    (packet->interface->hw_address.hlen != packet->raw->hlen) ||
869
	    (packet->interface->hw_address.hlen != packet->raw->hlen) ||
845
	    (memcmp(packet->interface->hw_address.haddr,
870
	    (memcmp(packet->interface->hw_address.haddr,
846
	    packet->raw->chaddr, packet->raw->hlen)))
871
	    packet->raw->chaddr, packet->raw->hlen))
872
	  )
847
		return;
873
		return;
848
874
849
	note("%s from %s", name, piaddr(packet->client_addr));
875
	note("%s from %s", name, piaddr(packet->client_addr));

Return to bug 128605