Skip to content

Commit

Permalink
Backported igmp_start_timer (#2937)
Browse files Browse the repository at this point in the history
Backport from upstream lwip to fix possible division by zero error when igmp max_time == 1
  • Loading branch information
pljakobs authored Jan 27, 2025
1 parent 73ac2fb commit 08130a0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ index eaa8dd6..6568657 100644
#endif

/**
@@ -1992,7 +1990,7 @@
@@ -1992,7 +1990,7 @@igmp_start_timer
* TCP_RST_DEBUG: Enable debugging for TCP with the RST message.
*/
#ifndef TCP_RST_DEBUG
Expand Down Expand Up @@ -714,3 +714,27 @@ index 6196784..6fd0eb9 100644
struct tcp_pcb* pcb;
struct tcp_seg *head = NULL;
struct tcp_seg *seg1 = NULL;

diff --git a/lwip/core/ipv4/igmp.c b/lwip/core/ipv4/igmp.c
index 2bb69e4..9562eea 100644
--- a/lwip/core/ipv4/igmp.c
+++ b/lwip/core/ipv4/igmp.c
@@ -702,12 +702,11 @@ igmp_timeout(struct igmp_group *group)
static void
igmp_start_timer(struct igmp_group *group, u8_t max_time)
{
- /* ensure the input value is > 0 */
- if (max_time == 0) {
- max_time = 1;
+ group->timer = (u16_t)(max_time > 2 ? (LWIP_RAND() % max_time) : 1);
+
+ if (group->timer == 0) {
+ group->timer = 1;
}
- /* ensure the random value is > 0 */
- group->timer = (LWIP_RAND() % (max_time - 1)) + 1;
}

/**


0 comments on commit 08130a0

Please sign in to comment.