aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-21 22:35:17 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-12-21 22:45:52 +0000
commitc794d188222a4d3414233ff9630d47eedc090fbe (patch)
tree18e51b77d0ae24c18d2799a2c4b2a70e65789e89
parent5d21ac643bb2a8d265470bf69043e50f060169d9 (diff)
downloadsrc-c794d188222a4d3414233ff9630d47eedc090fbe.tar.gz
src-c794d188222a4d3414233ff9630d47eedc090fbe.zip
Fix snprintf truncation in telnet
Building telnet with clang 18 results in the following warning: contrib/telnet/telnet/telnet.c:231:5: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 11 [-Werror,-Wformat-truncation] 231 | snprintf(temp2, sizeof(temp2), "%c%c%c%c....%c%c", IAC, SB, TELOPT_COMPORT, | ^ The temp2 buffer is 10 chars, while the format string also consists of 10 chars. Therefore, snprintf(3) will truncate the last character, 'SE' (end sub negotation) in this case. Bump the buffer to 11 chars to avoid truncation. MFC after: 3 days
-rw-r--r--contrib/telnet/telnet/telnet.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/contrib/telnet/telnet/telnet.c b/contrib/telnet/telnet/telnet.c
index a35ea40c4cd8..c936a85c9a23 100644
--- a/contrib/telnet/telnet/telnet.c
+++ b/contrib/telnet/telnet/telnet.c
@@ -206,7 +206,7 @@ unsigned char ComPortBaudRate[256];
void
DoBaudRate(char *arg)
{
- char *temp, temp2[10];
+ char *temp, temp2[11];
int i;
uint32_t baudrate;