Module Name: src
Committed By: joerg
Date: Fri Sep 16 15:36:01 UTC 2011
Modified Files:
src/crypto/external/bsd/openssh/dist: log.c
Log Message:
Reapply formatting cleanup
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/crypto/external/bsd/openssh/dist/log.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/external/bsd/openssh/dist/log.c
diff -u src/crypto/external/bsd/openssh/dist/log.c:1.5 src/crypto/external/bsd/openssh/dist/log.c:1.6
--- src/crypto/external/bsd/openssh/dist/log.c:1.5 Wed Sep 7 17:49:19 2011
+++ src/crypto/external/bsd/openssh/dist/log.c Fri Sep 16 15:36:00 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: log.c,v 1.5 2011/09/07 17:49:19 christos Exp $ */
+/* $NetBSD: log.c,v 1.6 2011/09/16 15:36:00 joerg Exp $ */
/* $OpenBSD: log.c,v 1.42 2011/06/17 21:44:30 djm Exp $ */
/*
* Author: Tatu Ylonen <[email protected]>
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-__RCSID("$NetBSD: log.c,v 1.5 2011/09/07 17:49:19 christos Exp $");
+__RCSID("$NetBSD: log.c,v 1.6 2011/09/16 15:36:00 joerg Exp $");
#include <sys/types.h>
#include <sys/uio.h>
@@ -325,8 +325,10 @@
#ifdef SYSLOG_DATA_INIT
struct syslog_data sdata = SYSLOG_DATA_INIT;
#endif
- char msgbuf[MSGBUFSIZ];
+ char msgbuf[MSGBUFSIZ], *msgbufp;
char visbuf[MSGBUFSIZ * 4 + 1];
+ size_t len, len2;
+ int len3;
const char *txt = NULL;
int pri = LOG_INFO;
int saved_errno = errno;
@@ -369,13 +371,19 @@
pri = LOG_ERR;
break;
}
+ len = sizeof(msgbuf);
+ msgbufp = msgbuf;
if (txt != NULL && log_handler == NULL) {
- snprintf(visbuf, sizeof(visbuf), "%s: %s", txt, fmt);
- vsnprintf(msgbuf, sizeof(msgbuf), visbuf, args);
- } else {
- vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
+ len2 = strlen(txt);
+ if (len2 >= len)
+ len2 = len - 1;
+ memcpy(msgbufp, txt, len2);
+ msgbufp += len2;
+ *msgbufp++ = '\0';
+ len -= len2 + 1;
}
- strnvis(visbuf, sizeof(visbuf), msgbuf, VIS_SAFE|VIS_OCTAL);
+ vsnprintf(msgbufp, len, fmt, args);
+ len3 = strnvis(visbuf, sizeof(visbuf), msgbuf, VIS_SAFE|VIS_OCTAL);
if (log_handler != NULL) {
/* Avoid recursion */
tmp_handler = log_handler;
@@ -383,8 +391,11 @@
tmp_handler(level, visbuf, log_handler_ctx);
log_handler = tmp_handler;
} else if (log_on_stderr) {
- snprintf(msgbuf, sizeof msgbuf, "%s\r\n", visbuf);
- write(STDERR_FILENO, msgbuf, strlen(msgbuf));
+ struct iovec iov[] = {
+ { visbuf, len3 },
+ { __UNCONST("\r\n"), 2 },
+ };
+ writev(STDERR_FILENO, iov, __arraycount(iov));
} else {
#ifdef SYSLOG_DATA_INIT
openlog_r(argv0 ? argv0 : __progname, LOG_PID, log_facility, &sdata);