From owner-freebsd-bugs Thu Oct 25 4:50: 9 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B217F37B405 for ; Thu, 25 Oct 2001 04:50:04 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f9PBo4G83042; Thu, 25 Oct 2001 04:50:04 -0700 (PDT) (envelope-from gnats) Date: Thu, 25 Oct 2001 04:50:04 -0700 (PDT) Message-Id: <200110251150.f9PBo4G83042@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Crist J. Clark" Subject: Re: bin/31483: minor correction in error message printed by acpiconf.8 Reply-To: "Crist J. Clark" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/31483; it has been noted by GNATS. From: "Crist J. Clark" To: Peter Pentchev Cc: freebsd-gnats-submit@FreeBSD.ORG, msmith@FreeBSD.ORG, iwasaki@FreeBSD.ORG Subject: Re: bin/31483: minor correction in error message printed by acpiconf.8 Date: Thu, 25 Oct 2001 04:43:58 -0700 On Thu, Oct 25, 2001 at 03:50:02AM -0700, Peter Pentchev wrote: > The following reply was made to PR bin/31483; it has been noted by GNATS. > > From: Peter Pentchev > To: Giorgos Keramidas > Cc: FreeBSD-gnats-submit@freebsd.org > Subject: Re: bin/31483: minor correction in error message printed by acpiconf.8 > Date: Thu, 25 Oct 2001 13:35:02 +0300 > > On Thu, Oct 25, 2001 at 03:17:55AM +0300, Giorgos Keramidas wrote: > > > > >Number: 31483 > > >Category: bin > > >Synopsis: minor correction in error message printed by acpiconf.8 > > >Originator: Giorgos Keramidas > > >Release: FreeBSD 5.0-CURRENT i386 > > [snip] > > > - err(1, NULL); > > + err(1, ACPIDEV); > > Just as an idea.. err(1, "%s", ACPIDEV)? :) ACPIDEV is a #define'd constant string. It is not a security vulnerability to use it as the original poster did. The original poster's code is, err(1, "/dev/acpi"); By the time the compiler gets to it. No format string vulnerability. Anyway, here is a general err.h and sysexits.h cleanup of the program that I'll commit if msmith and iwasaki don't mind, Index: usr.sbin/acpi/acpiconf/acpiconf.c =================================================================== RCS file: /export/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.c,v retrieving revision 1.6 diff -u -r1.6 acpiconf.c --- usr.sbin/acpi/acpiconf/acpiconf.c 2001/07/21 21:51:44 1.6 +++ usr.sbin/acpi/acpiconf/acpiconf.c 2001/10/25 11:30:33 @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -49,10 +50,10 @@ fd = open(ACPIDEV, O_RDWR); if (fd == -1) { - err(1, NULL); + err(EX_OSFILE, ACPIDEV); } if (ioctl(fd, enable, NULL) == -1) { - err(1, NULL); + err(EX_IOERR, NULL); } close(fd); @@ -66,10 +67,10 @@ fd = open(ACPIDEV, O_RDWR); if (fd == -1) { - err(1, NULL); + err(EX_OSFILE, ACPIDEV); } if (ioctl(fd, ACPIIO_SETSLPSTATE, &sleep_type) == -1) { - err(1, NULL); + err(EX_IOERR, NULL); } close(fd); @@ -107,11 +108,9 @@ case 's': sleep_type = optarg[0] - '0'; - if (sleep_type < 0 || sleep_type > 5) { - fprintf(stderr, "%s: invalid sleep type (%d)\n", - argv[0], sleep_type); - return -1; - } + if (sleep_type < 0 || sleep_type > 5) + errx(EX_USAGE, "invalid sleep type (%d)", + sleep_type); break; default: argc -= optind; -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message