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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user