https://bugzilla.mindrot.org/show_bug.cgi?id=2688
Bug ID: 2688
Summary: Long log messages to stderr missing newlines
Product: Portable OpenSSH
Version: 7.4p1
Hardware: All
OS: Linux
Status: NEW
Severity: minor
Priority: P5
Component: sshd
Assignee: [email protected]
Reporter: [email protected]
When logging to standard error (via -e) or to log file (via -E
<logfile>), long log messages do not end with a newline.
Problem occurs in log.c, line 456 in OpenSSH 7.4p1.
The snprintf() call attempts to copy fmtbuf and "\r\n" into msgbuf.
However, fmtbuf and msgbuf are the same size (MSGBUFSIZ, nominally 1024
bytes). When fmtbuf is completely filled (due to long log message),
then the snprintf() simply copies fmtbuf and ignores the "\r\n".
This was observed when testing certificate-based logins at LogLevel
DEBUG3.
For example, 3 logs messages appear on one line like this (with ...
replacing long OpenSSH certificate public key):
debug2: user_key_allowed: check options: '[email protected]
AAAA...debug2: user_key_allowed: advance: 'AAAA...debug2: key not found
Notice multiple debug2 messages all on the same line. Each log line
should with with a newline character.
Suggested Fix
Since the intent is to append "\r\n" to fmtbuf before writing to
stderr, maybe it would be better to make that intent clearer using
strlcat() rather than snprintf().
msgbuf[0] = '\0';
(void)strlcat(msgbuf, fmtbuf, sizeof msgbuf - 2);
(void)strlcat(msgbuf, "\r\n", sizeof msgbuf );
--
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
[email protected]
https://lists.mindrot.org/mailman/listinfo/openssh-bugs