Replace 308 with DHCP_OPTIONS_BUFSIZE in options.c.

This commit is contained in:
Nicholas J. Kain 2010-11-14 02:02:32 -05:00
parent 4ce4323d00
commit 1ffd1d9df3

View File

@ -61,7 +61,7 @@ int option_lengths[] = {
/* get an option with bounds checking (warning, not aligned). */ /* get an option with bounds checking (warning, not aligned). */
unsigned char *get_option(struct dhcpMessage *packet, int code) unsigned char *get_option(struct dhcpMessage *packet, int code)
{ {
int i = 0, length = 308; int i = 0, length = DHCP_OPTIONS_BUFSIZE;
unsigned char *optionptr; unsigned char *optionptr;
int over = 0, done = 0, curr = OPTION_FIELD; int over = 0, done = 0, curr = OPTION_FIELD;
@ -116,13 +116,13 @@ int end_option(unsigned char *optionptr)
{ {
int i = 0; int i = 0;
while (i < 308 && optionptr[i] != DHCP_END) { while (i < DHCP_OPTIONS_BUFSIZE && optionptr[i] != DHCP_END) {
if (optionptr[i] == DHCP_PADDING) if (optionptr[i] == DHCP_PADDING)
++i; ++i;
else else
i += optionptr[i + OPT_LEN] + 2; i += optionptr[i + OPT_LEN] + 2;
} }
return (i < 308 ? i : 308); return (i < DHCP_OPTIONS_BUFSIZE ? i : DHCP_OPTIONS_BUFSIZE);
} }
@ -133,7 +133,7 @@ int add_option_string(unsigned char *optionptr, unsigned char *string)
int end = end_option(optionptr); int end = end_option(optionptr);
/* end position + string length + option code/length + end option */ /* end position + string length + option code/length + end option */
if (end + string[OPT_LEN] + 2 + 1 >= 308) { if (end + string[OPT_LEN] + 2 + 1 >= DHCP_OPTIONS_BUFSIZE) {
log_error("Option 0x%02x did not fit into the packet!", log_error("Option 0x%02x did not fit into the packet!",
string[OPT_CODE]); string[OPT_CODE]);
return 0; return 0;