Pārlūkot izejas kodu

Fail gracefully when set_dhcp_option() is called with options==NULL.

tags/v0.9.3
Michael Brown 19 gadus atpakaļ
vecāks
revīzija
db0ff1731f
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6
    1
      src/net/dhcpopts.c

+ 6
- 1
src/net/dhcpopts.c Parādīt failu

409
 				       const void *data, size_t len ) {
409
 				       const void *data, size_t len ) {
410
 	static const uint8_t empty_encapsulator[] = { DHCP_END };
410
 	static const uint8_t empty_encapsulator[] = { DHCP_END };
411
 	struct dhcp_option *option;
411
 	struct dhcp_option *option;
412
-	void *insertion_point = options->data;
412
+	void *insertion_point;
413
 	struct dhcp_option *encapsulator = NULL;
413
 	struct dhcp_option *encapsulator = NULL;
414
 	unsigned int encap_tag = DHCP_ENCAPSULATOR ( tag );
414
 	unsigned int encap_tag = DHCP_ENCAPSULATOR ( tag );
415
 	size_t old_len = 0;
415
 	size_t old_len = 0;
416
 	size_t new_len = ( len ? ( len + DHCP_OPTION_HEADER_LEN ) : 0 );
416
 	size_t new_len = ( len ? ( len + DHCP_OPTION_HEADER_LEN ) : 0 );
417
 
417
 
418
+	/* Return NULL if no options block specified */
419
+	if ( ! options )
420
+		return NULL;
421
+
418
 	/* Find old instance of this option, if any */
422
 	/* Find old instance of this option, if any */
419
 	option = find_dhcp_option_with_encap ( options, tag, &encapsulator );
423
 	option = find_dhcp_option_with_encap ( options, tag, &encapsulator );
420
 	if ( option ) {
424
 	if ( option ) {
428
 	}
432
 	}
429
 	
433
 	
430
 	/* Ensure that encapsulator exists, if required */
434
 	/* Ensure that encapsulator exists, if required */
435
+	insertion_point = options->data;
431
 	if ( DHCP_IS_ENCAP_OPT ( tag ) ) {
436
 	if ( DHCP_IS_ENCAP_OPT ( tag ) ) {
432
 		if ( ! encapsulator )
437
 		if ( ! encapsulator )
433
 			encapsulator = set_dhcp_option ( options, encap_tag,
438
 			encapsulator = set_dhcp_option ( options, encap_tag,

Notiek ielāde…
Atcelt
Saglabāt