Skip to contentSkip to conversation

ip: ipmaddr.c: Fix possible integer underflow in read_igmp()

PATCH Applied Anton Moryakov 2 participants 2 messages Jul 20, 2025 – Jul 29, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ip: ipmaddr.c: Fix possible integer underflow in read_igmp()

Static analyzer pointed out a potential error:

Possible integer underflow: left operand is tainted. An integer underflow may occur due to arithmetic operation (unsigned subtraction) between variable 'len' and value '1', when 'len' is tainted { [0, 18446744073709551615] }

The fix adds a check for 'len == 0' before accessing the last character of the name, and skips the current line in such cases to avoid the underflow.

Reported-by SVACE static analyzer
---
 ip/ipmaddr.c | 2 ++
 1 file changed, 2 insertions(+)
ip/ipmaddr.c +2 -0
index 2418b303..2feb916a 100644
@@ -150,6 +150,8 @@ static void read_igmp(struct ma_info **result_p)
 
 			sscanf(buf, "%d%s", &m.index, m.name);
 			len = strlen(m.name);
+			if (len == 0)
+				continue;
 			if (m.name[len - 1] == ':')
 				m.name[len - 1] = '\0';
 			continue;
Signature · 1 line
2.39.2
#1 lore raw
This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 10 lines · On Sun, 20 Jul 2025 18:38:43 +0300 you wrote:

Static analyzer pointed out a potential error:

Possible integer underflow: left operand is tainted. An integer underflow may occur due to arithmetic operation (unsigned subtraction) between variable 'len' and value '1', when 'len' is tainted { [0, 18446744073709551615] }

The fix adds a check for 'len == 0' before accessing the last character of the name, and skips the current line in such cases to avoid the underflow.

[...]

Here is the summary with links:
- [V2,iproute2-next] ip: ipmaddr.c: Fix possible integer underflow in read_igmp()

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=5734dc8aa703

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html