From: Stephen Hemminger Date: Mon, 18 Sep 2023 18:36:32 +0000 (-0700) Subject: ila: fix potential snprintf buffer overflow X-Git-Tag: v6.6.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8a3fca81cd4b8fee14cfb14a5ce9c1b3b63e797;p=thirdparty%2Fiproute2.git 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 --- 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; } }