[PATCH] Large log output does not print newline
Oliver Gasser
gasser at in.tum.de
Tue Dec 11 23:53:02 EST 2012
Hi,
can anyone take a look at the bug and the patch for it?
Here is my original email message:
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.
Patch is attached.
Thank you,
Oliver
On Wed, Dec 5, 2012 at 9:09 AM, Oliver Gasser <gasser at in.tum.de> wrote:
> 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 {
More information about the openssh-unix-dev
mailing list