public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipmaddr: Add check for result of sscanf
@ 2024-02-18 20:42 Maks Mishin
  2024-02-19 17:31 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Maks Mishin @ 2024-02-18 20:42 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Maks Mishin, netdev

Added comparison of result sscanf with 2 to avoid
potential troubles with args of sscanf.
Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 ip/ipmaddr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c
index 2418b303..00e91004 100644
--- a/ip/ipmaddr.c
+++ b/ip/ipmaddr.c
@@ -148,7 +148,9 @@ static void read_igmp(struct ma_info **result_p)
 		if (buf[0] != '\t') {
 			size_t len;
 
-			sscanf(buf, "%d%s", &m.index, m.name);
+			if (sscanf(buf, "%d%s", &m.index, m.name) != 2)
+				return;
+
 			len = strlen(m.name);
 			if (m.name[len - 1] == ':')
 				m.name[len - 1] = '\0';
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-19 17:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18 20:42 [PATCH] ipmaddr: Add check for result of sscanf Maks Mishin
2024-02-19 17:31 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox