|
@@ -409,12 +409,16 @@ struct dhcp_option * set_dhcp_option ( struct dhcp_option_block *options,
|
409
|
409
|
const void *data, size_t len ) {
|
410
|
410
|
static const uint8_t empty_encapsulator[] = { DHCP_END };
|
411
|
411
|
struct dhcp_option *option;
|
412
|
|
- void *insertion_point = options->data;
|
|
412
|
+ void *insertion_point;
|
413
|
413
|
struct dhcp_option *encapsulator = NULL;
|
414
|
414
|
unsigned int encap_tag = DHCP_ENCAPSULATOR ( tag );
|
415
|
415
|
size_t old_len = 0;
|
416
|
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
|
422
|
/* Find old instance of this option, if any */
|
419
|
423
|
option = find_dhcp_option_with_encap ( options, tag, &encapsulator );
|
420
|
424
|
if ( option ) {
|
|
@@ -428,6 +432,7 @@ struct dhcp_option * set_dhcp_option ( struct dhcp_option_block *options,
|
428
|
432
|
}
|
429
|
433
|
|
430
|
434
|
/* Ensure that encapsulator exists, if required */
|
|
435
|
+ insertion_point = options->data;
|
431
|
436
|
if ( DHCP_IS_ENCAP_OPT ( tag ) ) {
|
432
|
437
|
if ( ! encapsulator )
|
433
|
438
|
encapsulator = set_dhcp_option ( options, encap_tag,
|