Преглед изворни кода

When the DHCP file/sname fields are empty, don't allow them to override

their equivalent DHCP-option-specified values.
tags/v0.9.3
Michael Brown пре 16 година
родитељ
комит
3311169707
1 измењених фајлова са 8 додато и 6 уклоњено
  1. 8
    6
      src/net/udp/dhcp.c

+ 8
- 6
src/net/udp/dhcp.c Прегледај датотеку

@@ -368,11 +368,11 @@ static size_t dhcp_field_len ( const void *data, size_t max_len ) {
368 368
  * @v max_len		Field length
369 369
  * @v tag		DHCP option tag, or 0
370 370
  *
371
- * If @c tag is non-zero, the field will be treated as a
372
- * NUL-terminated string representing the value of the specified DHCP
373
- * option.  If @c tag is zero, the field will be treated as a block of
374
- * DHCP options, and simply appended to the existing options in the
375
- * option block.
371
+ * If @c tag is non-zero (and the field is not empty), the field will
372
+ * be treated as a NUL-terminated string representing the value of the
373
+ * specified DHCP option.  If @c tag is zero, the field will be
374
+ * treated as a block of DHCP options, and simply appended to the
375
+ * existing options in the option block.
376 376
  *
377 377
  * The caller must ensure that there is enough space in the options
378 378
  * block to perform the merge.
@@ -385,7 +385,9 @@ static void merge_dhcp_field ( struct dhcp_option_block *options,
385 385
 	struct dhcp_option *end;
386 386
 
387 387
 	if ( tag ) {
388
-		set_dhcp_option ( options, tag, data, strlen ( data ) );
388
+		len = strlen ( data );
389
+		if ( len )
390
+			set_dhcp_option ( options, tag, data, len );
389 391
 	} else {
390 392
 		len = dhcp_field_len ( data, max_len );
391 393
 		dest = ( options->data + options->len - 1 );

Loading…
Откажи
Сачувај