Update of /cvsroot/dhcp-agent/dhcp-agent/src
In directory sc8-pr-cvs1:/tmp/cvs-serv14579/src
Modified Files:
dhcp-com.c dhcp-librawnet.h
Log Message:
unhandled dhcp options are now ignored instead of causing processing to stop
Index: dhcp-com.c
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-com.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** dhcp-com.c 4 May 2003 18:52:19 -0000 1.11
--- dhcp-com.c 26 Jun 2003 13:55:09 -0000 1.12
***************
*** 78,86 ****
dhcp_opt_t *option;
! /* Check for malformed option. */
! if(len < 2 || /* is len smaller than 2? (it can never be) */
! !dhcp_option_is_valid(opt_data[0], opt_data[1]) /* is the tag and len valid? */
! || len < opt_data[1]) /* finally is there as much space as is claimed? */
return NULL;
--- 78,85 ----
dhcp_opt_t *option;
! /* Make sure the current packet length is big enough to hold
! * the whole option. */
! if(len < 2 || (len - 2) < opt_data[1])
return NULL;
***************
*** 94,97 ****
--- 93,106 ----
}
+ static int skip_option(const uint8_t *opt_data, int len, uint8_t *optlen)
+ {
+ if(len < 2 || (len - 2) < opt_data[1])
+ return 1;
+
+ *optlen = opt_data[1];
+ return 0;
+ }
+
+
static void dhcp_read_options_image(dhcp_obj * dhcp, const uint8_t *dhcp_packet, int len)
{
***************
*** 125,135 ****
break;
! /* If not PAD or END we copy the data out. */
! option = process_next_dhcp_option(dhcp_packet, len, &optlen);
! if(option == NULL)
! break;
! list_add_to_end(dhcp->options, option);
len -= (optlen + 2);
--- 134,151 ----
break;
! /* ignore options we cannot handle. */
! if(*dhcp_packet > MAX_OPTIONS_HANDLED) {
! if(skip_option(dhcp_packet, len, &optlen))
! break;
! } else {
!
! option = process_next_dhcp_option(dhcp_packet, len, &optlen);
! if(option == NULL)
! break;
!
! list_add_to_end(dhcp->options, option);
! }
len -= (optlen + 2);
***************
*** 475,487 ****
return 0;
- }
-
- /* test for option validity. */
- int dhcp_option_is_valid(uint8_t tag, uint8_t tag_len)
- {
- if(tag_len < 1 || tag > MAX_OPTIONS_HANDLED)
- return 0;
- else
- return 1;
}
--- 491,494 ----
Index: dhcp-librawnet.h
===================================================================
RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-librawnet.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** dhcp-librawnet.h 25 Jun 2003 01:54:14 -0000 1.17
--- dhcp-librawnet.h 26 Jun 2003 13:55:09 -0000 1.18
***************
*** 473,477 ****
extern int dhcp_valid_magic_cookie(dhcp_obj * dhcp);
extern int dhcp_is_type(dhcp_obj * dhcp, uint8_t type);
- extern int dhcp_option_is_valid(uint8_t tag, uint8_t tag_len);
extern int dhcp_have_option(dhcp_obj *dhcp, uint8_t tag);
extern int dhcp_is_file_overload(dhcp_obj * dhcp);
--- 473,476 ----
|