@@ -298,7 +298,8 @@ static void ICACHE_FLASH_ATTR send_offer(struct dhcps_msg *m)
298
298
end = add_offer_options (end );
299
299
end = add_end (end );
300
300
301
- p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ), PBUF_RAM );
301
+ // ensure that not more than the minimum options length is transmitted
302
+ p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ) - sizeof (m -> options ) + DHCP_MSGOPTIONS_MIN_LEN , PBUF_RAM );
302
303
#if DHCPS_DEBUG
303
304
os_printf ("udhcp: send_offer>>p->ref = %d\n" , p -> ref );
304
305
#endif
@@ -358,7 +359,8 @@ static void ICACHE_FLASH_ATTR send_nak(struct dhcps_msg *m)
358
359
end = add_msg_type (& m -> options [4 ], DHCPNAK );
359
360
end = add_end (end );
360
361
361
- p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ), PBUF_RAM );
362
+ // ensure that not more than the minimum options length is transmitted
363
+ p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ) - sizeof (m -> options ) + DHCP_MSGOPTIONS_MIN_LEN , PBUF_RAM );
362
364
#if DHCPS_DEBUG
363
365
os_printf ("udhcp: send_nak>>p->ref = %d\n" , p -> ref );
364
366
#endif
@@ -418,8 +420,9 @@ static void ICACHE_FLASH_ATTR send_ack(struct dhcps_msg *m)
418
420
end = add_msg_type (& m -> options [4 ], DHCPACK );
419
421
end = add_offer_options (end );
420
422
end = add_end (end );
421
-
422
- p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ), PBUF_RAM );
423
+
424
+ // ensure that not more than the minimum options length is transmitted
425
+ p = pbuf_alloc (PBUF_TRANSPORT , sizeof (struct dhcps_msg ) - sizeof (m -> options ) + DHCP_MSGOPTIONS_MIN_LEN , PBUF_RAM );
423
426
#if DHCPS_DEBUG
424
427
os_printf ("udhcp: send_ack>>p->ref = %d\n" , p -> ref );
425
428
#endif
0 commit comments