28 lines
816 B
Diff
28 lines
816 B
Diff
From e8a3fca81cd4b8fee14cfb14a5ce9c1b3b63e797 Mon Sep 17 00:00:00 2001
|
|
From: Stephen Hemminger <stephen@networkplumber.org>
|
|
Date: Mon, 18 Sep 2023 11:36:32 -0700
|
|
Subject: [PATCH] ila: fix potential snprintf buffer overflow
|
|
|
|
The code to print 64 bit address has a theoretical overflow
|
|
of snprintf buffer found by CodeQL scan.
|
|
Address by checking result.
|
|
|
|
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
|
---
|
|
ip/ipila.c | 2 ++
|
|
1 file changed, 2 insertions(+)
|
|
|
|
diff --git a/ip/ipila.c b/ip/ipila.c
|
|
index 4f6d578f2..23b19a108 100644
|
|
--- a/ip/ipila.c
|
|
+++ b/ip/ipila.c
|
|
@@ -60,6 +60,8 @@ static void print_addr64(__u64 addr, char *buff, size_t len)
|
|
sep = "";
|
|
|
|
ret = snprintf(&buff[written], len - written, "%x%s", v, sep);
|
|
+ if (ret < 0 || ret >= len - written)
|
|
+ break;
|
|
written += ret;
|
|
}
|
|
}
|