Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/mopd/common Fix broken snprintf usage; noted in PR ...
details: https://anonhg.NetBSD.org/src/rev/bb4e2b4e1ce2
branches: trunk
changeset: 797784:bb4e2b4e1ce2
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jul 27 04:38:03 2014 +0000
description:
Fix broken snprintf usage; noted in PR 47976 from Henning Petersen.
As a bonus, this removes the nonliteral format arguments.
diffstat:
usr.sbin/mopd/common/Makefile | 3 +--
usr.sbin/mopd/common/log.c | 16 ++++++++++------
2 files changed, 11 insertions(+), 8 deletions(-)
diffs (68 lines):
diff -r 827007818b3f -r bb4e2b4e1ce2 usr.sbin/mopd/common/Makefile
--- a/usr.sbin/mopd/common/Makefile Sun Jul 27 04:32:23 2014 +0000
+++ b/usr.sbin/mopd/common/Makefile Sun Jul 27 04:38:03 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.19 2012/08/10 12:10:29 joerg Exp $
+# $NetBSD: Makefile,v 1.20 2014/07/27 04:38:03 dholland Exp $
LIBISPRIVATE= yes
@@ -21,4 +21,3 @@
.include <bsd.lib.mk>
COPTS.print.c+= -Wno-pointer-sign
-COPTS.log.c+= -Wno-format-nonliteral
diff -r 827007818b3f -r bb4e2b4e1ce2 usr.sbin/mopd/common/log.c
--- a/usr.sbin/mopd/common/log.c Sun Jul 27 04:32:23 2014 +0000
+++ b/usr.sbin/mopd/common/log.c Sun Jul 27 04:38:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: log.c,v 1.2 2008/04/28 20:24:17 martin Exp $ */
+/* $NetBSD: log.c,v 1.3 2014/07/27 04:38:03 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: log.c,v 1.2 2008/04/28 20:24:17 martin Exp $");
+__RCSID("$NetBSD: log.c,v 1.3 2014/07/27 04:38:03 dholland Exp $");
#endif
#include <err.h>
@@ -47,13 +47,15 @@
{
va_list ap;
char buf[1024];
+ int error;
va_start(ap, fmt);
if (mopInteractive)
verr(1, fmt, ap);
else {
- snprintf(buf, sizeof(buf), "%s: %%m", buf);
- vsyslog(LOG_ERR, buf, ap);
+ error = errno;
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ syslog(LOG_ERR, "%s: %s", buf, strerror(error));
}
va_end(ap);
exit(1);
@@ -64,13 +66,15 @@
{
va_list ap;
char buf[1024];
+ int error;
va_start(ap, fmt);
if (mopInteractive)
vwarn(fmt, ap);
else {
- snprintf(buf, sizeof(buf), "%s: %%m", buf);
- vsyslog(LOG_WARNING, buf, ap);
+ error = errno;
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ syslog(LOG_WARNING, "%s: %s", buf, strerror(error));
}
va_end(ap);
}
Home |
Main Index |
Thread Index |
Old Index