Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 185472
Collapse All | Expand All

(-)dhcp.c (-4 / +36 lines)
Lines 464-474 Link Here
464
	route_t *static_routes = NULL;
464
	route_t *static_routes = NULL;
465
	route_t *static_routesp = NULL;
465
	route_t *static_routesp = NULL;
466
	route_t *csr = NULL;
466
	route_t *csr = NULL;
467
	bool in_overload = false;
468
	bool parse_sname = false;
469
	bool parse_file = false;
467
470
468
	end += sizeof (message->options);
471
	end += sizeof (message->options);
469
472
470
	dhcp->address.s_addr = message->yiaddr;
473
	dhcp->address.s_addr = message->yiaddr;
471
	strlcpy (dhcp->servername, message->servername,
474
	strlcpy (dhcp->servername, (char *) message->servername,
472
			 sizeof (dhcp->servername));
475
			 sizeof (dhcp->servername));
473
476
474
#define LEN_ERR \
477
#define LEN_ERR \
Lines 478-488 Link Here
478
		continue; \
481
		continue; \
479
	}
482
	}
480
483
484
parse_start:
481
	while (p < end) {
485
	while (p < end) {
482
		option = *p++;
486
		option = *p++;
483
		if (! option)
487
		if (! option)
484
			continue;
488
			continue;
485
489
490
		if (option == DHCP_END)
491
			goto eexit;
492
486
		length = *p++;
493
		length = *p++;
487
494
488
		if (p + length >= end) {
495
		if (p + length >= end) {
Lines 492-500 Link Here
492
		}
499
		}
493
500
494
		switch (option) {
501
		switch (option) {
495
			case DHCP_END:
496
				goto eexit;
497
498
			case DHCP_MESSAGETYPE:
502
			case DHCP_MESSAGETYPE:
499
				retval = (int) *p;
503
				retval = (int) *p;
500
				p += length;
504
				p += length;
Lines 657-662 Link Here
657
				}
661
				}
658
				break;
662
				break;
659
663
664
			case DHCP_OPTIONSOVERLOADED:
665
				LENGTH (1);
666
				/* The overloaded option in an overloaded option
667
				 * should be ignored, overwise we may get an infinite loop */
668
				if (! in_overload) {
669
					if (*p & 1)
670
						parse_file = true;
671
					if (*p & 2)
672
						parse_sname = true;
673
				}
674
				break;
675
660
#undef LENGTH
676
#undef LENGTH
661
#undef MIN_LENGTH
677
#undef MIN_LENGTH
662
#undef MULT_LENGTH
678
#undef MULT_LENGTH
Lines 670-675 Link Here
670
	}
686
	}
671
687
672
eexit:
688
eexit:
689
	/* We may have options overloaded, so go back and grab them */
690
	if (parse_file) {
691
		parse_file = false;
692
		p = message->bootfile;
693
		end = p + sizeof (message->bootfile);
694
		in_overload = true;
695
		goto parse_start;
696
	} else if (parse_sname) {
697
		parse_sname = false;
698
		p = message->servername;
699
		end = p + sizeof (message->servername);
700
		memset (dhcp->servername, 0, sizeof (dhcp->servername));
701
		in_overload = true;
702
		goto parse_start;
703
	}
704
673
	/* Fill in any missing fields */
705
	/* Fill in any missing fields */
674
	if (! dhcp->netmask.s_addr)
706
	if (! dhcp->netmask.s_addr)
675
		dhcp->netmask.s_addr = getnetmask (dhcp->address.s_addr);
707
		dhcp->netmask.s_addr = getnetmask (dhcp->address.s_addr);
(-)dhcp.h (-2 / +3 lines)
Lines 83-88 Link Here
83
	DHCP_NTPSERVER              = 42,
83
	DHCP_NTPSERVER              = 42,
84
	DHCP_ADDRESS                = 50,
84
	DHCP_ADDRESS                = 50,
85
	DHCP_LEASETIME              = 51,
85
	DHCP_LEASETIME              = 51,
86
	DHCP_OPTIONSOVERLOADED      = 52,
86
	DHCP_MESSAGETYPE            = 53,
87
	DHCP_MESSAGETYPE            = 53,
87
	DHCP_SERVERIDENTIFIER       = 54,
88
	DHCP_SERVERIDENTIFIER       = 54,
88
	DHCP_PARAMETERREQUESTLIST   = 55,
89
	DHCP_PARAMETERREQUESTLIST   = 55,
Lines 184-191 Link Here
184
	int32_t siaddr;         /* should be zero in client's messages */
185
	int32_t siaddr;         /* should be zero in client's messages */
185
	int32_t giaddr;         /* should be zero in client's messages */
186
	int32_t giaddr;         /* should be zero in client's messages */
186
	unsigned char chaddr[DHCP_CHADDR_LEN];  /* client's hardware address */
187
	unsigned char chaddr[DHCP_CHADDR_LEN];  /* client's hardware address */
187
	char servername[SERVERNAME_LEN];    /* server host name */
188
	unsigned char servername[SERVERNAME_LEN];    /* server host name */
188
	char bootfile[BOOTFILE_LEN];    /* boot file name */
189
	unsigned char bootfile[BOOTFILE_LEN];    /* boot file name */
189
	uint32_t cookie;
190
	uint32_t cookie;
190
	unsigned char options[DHCP_OPTION_LEN]; /* message options - cookie */
191
	unsigned char options[DHCP_OPTION_LEN]; /* message options - cookie */
191
} dhcpmessage_t;
192
} dhcpmessage_t;

Return to bug 185472