Module Name:    src
Committed By:   dholland
Date:           Sun Jul 27 04:38:03 UTC 2014

Modified Files:
        src/usr.sbin/mopd/common: Makefile log.c

Log Message:
Fix broken snprintf usage; noted in PR 47976 from Henning Petersen.
As a bonus, this removes the nonliteral format arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/mopd/common/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/mopd/common/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/usr.sbin/mopd/common/Makefile
diff -u src/usr.sbin/mopd/common/Makefile:1.19 src/usr.sbin/mopd/common/Makefile:1.20
--- src/usr.sbin/mopd/common/Makefile:1.19	Fri Aug 10 12:10:29 2012
+++ src/usr.sbin/mopd/common/Makefile	Sun Jul 27 04:38:03 2014
@@ -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 @@ version.c: VERSION
 .include <bsd.lib.mk>
 
 COPTS.print.c+=	-Wno-pointer-sign
-COPTS.log.c+=	-Wno-format-nonliteral

Index: src/usr.sbin/mopd/common/log.c
diff -u src/usr.sbin/mopd/common/log.c:1.2 src/usr.sbin/mopd/common/log.c:1.3
--- src/usr.sbin/mopd/common/log.c:1.2	Mon Apr 28 20:24:17 2008
+++ src/usr.sbin/mopd/common/log.c	Sun Jul 27 04:38:03 2014
@@ -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 @@ mopLogErr(const char *fmt, ...)
 {
 	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 @@ mopLogWarn(const char *fmt, ...)
 {
 	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);
 }

Reply via email to