[Midnightbsd-cvs] [MidnightBSD/src] c21d23: Fix snprintf truncation in telnet
Dimitry Andric
noreply at github.com
Sun May 19 11:37:59 EDT 2024
Branch: refs/heads/stable/3.1
Home: https://github.com/MidnightBSD/src
Commit: c21d2301386d23e787e61756f3cf9704b94ae9f9
https://github.com/MidnightBSD/src/commit/c21d2301386d23e787e61756f3cf9704b94ae9f9
Author: Dimitry Andric <dim at FreeBSD.org>
Date: 2024-05-19 (Sun, 19 May 2024)
Changed paths:
M contrib/telnet/telnet/telnet.c
Log Message:
-----------
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
(cherry picked from commit c794d188222a4d3414233ff9630d47eedc090fbe)
To unsubscribe from these emails, change your notification settings at https://github.com/MidnightBSD/src/settings/notifications
More information about the Midnightbsd-cvs
mailing list