Subject: bin/7725: err.h uses gcc printf-style *fmt checking that does not account for a NULL argument
To: None <gnats-bugs@gnats.netbsd.org>
From: None <soren@t.dk>
List: netbsd-bugs
Date: 06/06/1999 19:20:57
>Number: 7725
>Category: bin
>Synopsis: err.h uses gcc printf-style *fmt checking that does not account for a NULL argument
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 6 19:20:01 1999
>Last-Modified:
>Originator: Soren S. Jorvang
>Organization:
Soren
>Release: NetBSD-current
>Environment:
System: NetBSD 1.4C i386
>Description:
The fmt argument of {,v}{err,warn}{,x} is special with regard to gcc's
builting printf-style formatting checker in that it may legally be a
NULL pointer.
Current gcc does not know about this. <err.h> just uses the plain
printf-style checking which has apparently provoked a number of
workarounds (see 'Fix:').
However, those workarounds produce incorrect output ala 'foo: : Some error'.
Perhaps gcc should be taught about err(3) and friends, but until that
happens, I think the argument checking for these functions should just be
relaxed.
>How-To-Repeat:
>Fix:
--- src/include/err.h.orig Mon Jun 7 03:48:48 1999
+++ src/include/err.h Mon Jun 7 03:50:50 1999
@@ -50,21 +50,17 @@
__BEGIN_DECLS
__dead void err __P((int, const char *, ...))
- __attribute__((__noreturn__, __format__(__printf__, 2, 3)));
+ __attribute__((__noreturn__));
__dead void verr __P((int, const char *, _BSD_VA_LIST_))
- __attribute__((__noreturn__, __format__(__printf__, 2, 0)));
+ __attribute__((__noreturn__));
__dead void errx __P((int, const char *, ...))
- __attribute__((__noreturn__, __format__(__printf__, 2, 3)));
+ __attribute__((__noreturn__));
__dead void verrx __P((int, const char *, _BSD_VA_LIST_))
- __attribute__((__noreturn__, __format__(__printf__, 2, 0)));
-void warn __P((const char *, ...))
- __attribute__((__format__(__printf__, 1, 2)));
-void vwarn __P((const char *, _BSD_VA_LIST_))
- __attribute__((__format__(__printf__, 1, 0)));
-void warnx __P((const char *, ...))
- __attribute__((__format__(__printf__, 1, 2)));
-void vwarnx __P((const char *, _BSD_VA_LIST_))
- __attribute__((__format__(__printf__, 1, 0)));
+ __attribute__((__noreturn__));
+void warn __P((const char *, ...));
+void vwarn __P((const char *, _BSD_VA_LIST_));
+void warnx __P((const char *, ...));
+void vwarnx __P((const char *, _BSD_VA_LIST_));
__END_DECLS
#endif /* !_ERR_H_ */
Also, the following calls of err(3) cause incorrect 'foo: : Some error' output.
They should all be changed to 'err(1, NULL);'.
src/bin/dd/dd.c:158: err(1, "%s", "");
src/bin/dd/dd.c:163: err(1, "%s", "");
src/bin/ps/keyword.c:229: err(1, "%s", "");
src/bin/ps/ps.c:358: err(1, "%s", "");
src/bin/ps/ps.c:486: err(1, "%s", "");
src/bin/rcp/rcp.c:197: err(1, "%s", "");
src/bin/rcp/rcp.c:283: err(1, "%s", "");
src/bin/rcp/rcp.c:308: err(1, "%s", "");
src/bin/rcp/rcp.c:344: err(1, "%s", "");
src/bin/rcp/rcp.c:369: err(1, "%s", "");
src/bin/rm/rm.c:176: err(1, "%s", "");
src/usr.sbin/netgroup_mkdb/util.c:55: err(1, "%s", "");
src/usr.sbin/netgroup_mkdb/util.c:71: err(1, "%s", "");
src/games/fortune/fortune/fortune.c:193: err(1, "%s", "")
src/games/fortune/fortune/fortune.c:849: err(1, "%s", "");
src/games/fortune/fortune/fortune.c:1233: err(1, "%s", "");
src/libexec/getNAME/getNAME.c:232: err(1, "%s", "");
src/libexec/getNAME/getNAME.c:333: err(1, "%s", "");
src/sbin/umount/umount.c:181: err(1, "%s", "");
src/sbin/init/init.c:200: err(1, "%s", "");
src/sbin/mount/getmntopts.c:72: err(1, "%s", "");
src/sbin/mount_cd9660/mount_cd9660.c:127: err(1, "%s", "");
src/sbin/mount_fdesc/mount_fdesc.c:97: err(1, "%s", "");
src/sbin/mount_lfs/mount_lfs.c:122: err(1, "%s", "");
src/sbin/mount_null/mount_null.c:109: err(1, "%s", "");
src/sbin/mount_procfs/mount_procfs.c:97: err(1, "%s", "");
src/sbin/mount_umap/mount_umap.c:233: err(1, "%s", "");
src/sbin/mount_union/mount_union.c:120: err(1, "%s", "");
src/sbin/restore/main.c:338: err(1, "%s", "");
src/sbin/restore/main.c:353: err(1, "%s", "");
src/sbin/route/show.c:123: err(1, "%s", "");
src/sbin/mount_kernfs/mount_kernfs.c:97: err(1, "%s", "");
src/sbin/mount_filecore/mount_filecore.c:141: err(1, "%s", "");
src/usr.bin/calendar/calendar.c:111: err(1, "%s", "");
src/usr.bin/find/function.c:1361: err(1, "%s", "");
src/usr.bin/finger/finger.c:229: err(1, "%s", ""); /* XXX gcc */
src/usr.bin/finger/util.c:210: err(1, "%s", "");
src/usr.bin/finger/util.c:272: err(1, "%s", "");
src/usr.bin/finger/util.c:287: err(1, "%s", "");
src/usr.bin/head/head.c:155: err(1, "%s", "");
src/usr.bin/hexdump/display.c:380: err(1, "%s", "");
src/usr.bin/id/id.c:134: err(1, "%s", "");
src/usr.bin/sed/process.c:535: err(1, "%s", "");
src/usr.bin/soelim/soelim.c:104: err(1, "%s", "");
src/usr.bin/soelim/soelim.c:108: err(1, "%s", "");
src/usr.bin/tset/term.c:126: err(1, "%s", "");
src/usr.bin/w/w.c:213: err(1, "%s", "");
src/usr.bin/whereis/whereis.c:102: err(1, "%s", "");
src/usr.bin/write/write.c:332:err: err(1, "%s", "");
src/usr.bin/xstr/xstr.c:362: err(1, "%s", "");
src/usr.bin/xstr/xstr.c:365: err(1, "%s", "");
>Audit-Trail:
>Unformatted: