Hi, I think I found a minor bug in OpenSSH's log functionality: If a log message which is larger than MSGBUFSIZE=1024 and logged to stderr, then the newline (\r\n) is not printed. This is due to the fact that the newline is added after the log message concatenated with "\r\n" is snprintf'd to another buffer of the same size. If the source buffer (fmtbuf) would already fill the destination buffer (msgbuf), then the additional "\r\n" are of course never written into the destination buffer. See the one-line attached patch. Could it be possible to make the size limit for log messages dynamic, e.g. via ssh_config? Or is the fixed limit of 1024 characters there on purpose? Kind regards, Oliver Gasser
Second try for the patch. Otherwise, here is the .patch's content:
diff --git a/log.c b/log.c
index ad5a10b..de3f451 100644
--- a/log.c
+++ b/log.c
@@ -413,6 +413,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
tmp_handler(level, fmtbuf, log_handler_ctx);
log_handler = tmp_handler;
} else if (log_on_stderr) {
+ fmtbuf[sizeof(fmtbuf)-3] = '\0';
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
write(STDERR_FILENO, msgbuf, strlen(msgbuf));
} else {
On Wed, Dec 5, 2012 at 3:15 AM, Peter Stuge <peter at stuge.se> wrote:
> Oliver Gasser wrote:
> > one-line attached patch.
>
> No patch. Make sure mimetype is text/plain.
>
>
> //Peter
>
-------------- next part --------------
diff --git a/log.c b/log.c
index ad5a10b..de3f451 100644
--- a/log.c
+++ b/log.c
@@ -413,6 +413,7 @@ do_log(LogLevel level, const char *fmt, va_list args)
tmp_handler(level, fmtbuf, log_handler_ctx);
log_handler = tmp_handler;
} else if (log_on_stderr) {
+ fmtbuf[sizeof(fmtbuf)-3] = '\0';
snprintf(msgbuf, sizeof msgbuf, "%s\r\n", fmtbuf);
write(STDERR_FILENO, msgbuf, strlen(msgbuf));
} else {
Apparently Analagous Threads
- [PATCH v2 1/1] paint visual host key with unicode box-drawing characters
- [PATCH 1/1] paint visual host key with unicode box-drawing characters
- [PATCH 1/1] paint visual host key with unicode box-drawing characters
- preauth privsep logging via monitor
- [PATCH 1/1] log: do not print carriage return