ip: ipmaddr.c: Fix possible integer underflow in read_igmp()
Subsystems (2)
PATCH 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.
--- ip/ipmaddr.c | 2 ++ 1 file changed, 2 insertions(+)
ip/ipmaddr.c +2 -0
@@ -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
Quoted 20 lines · On Sat, 19 Jul 2025 18:57:05 +0300 Anton Moryakov <[email protected]>…
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 analyzerSigned-off-by Anton Moryakov <[email protected]>--- ip/ipmaddr.c | 2 ++ 1 file changed, 2 insertions(+)ip/ipmaddr.c +0
-0
ip/ipmaddr.c static void read_igmp(struct ma_info **result_p) · line 154
Quoted 5 lines
ip/ipmaddr.c +2
-0@@ -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 ;
Need to follow kernel coding style, need space here.
if (len == 0) not if(len == 0)