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>
This commit is contained in:
Stephen Hemminger
2023-09-18 11:36:32 -07:00
parent 4d80122ae8
commit e8a3fca81c

View File

@@ -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;
}
}