From charon@labs.gr  Wed Oct 24 17:17:59 2001
Return-Path: <charon@labs.gr>
Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5])
	by hub.freebsd.org (Postfix) with ESMTP id 8070937B403
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Oct 2001 17:17:58 -0700 (PDT)
Received: from hades.hell.gr (patr530-a120.otenet.gr [212.205.215.120])
	by mailsrv.otenet.gr (8.11.5/8.11.5) with ESMTP id f9P0Hs529799
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Oct 2001 03:17:54 +0300 (EEST)
Received: (from charon@localhost)
	by hades.hell.gr (8.11.6/8.11.6) id f9P0Htq04307;
	Thu, 25 Oct 2001 03:17:55 +0300 (EEST)
	(envelope-from charon)
Message-Id: <200110250017.f9P0Htq04307@hades.hell.gr>
Date: Thu, 25 Oct 2001 03:17:55 +0300 (EEST)
From: Giorgos Keramidas <charon@labs.gr>
Reply-To: Giorgos Keramidas <charon@labs.gr>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: minor correction in error message printed by acpiconf.8
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         31483
>Category:       bin
>Synopsis:       minor correction in error message printed by acpiconf.8
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cjc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 24 17:20:00 PDT 2001
>Closed-Date:    Fri Nov 30 03:58:45 PST 2001
>Last-Modified:  Fri Nov 30 04:03:04 PST 2001
>Originator:     Giorgos Keramidas
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:

System: FreeBSD hades.hell.gr 5.0-CURRENT FreeBSD 5.0-CURRENT #0: \
Mon Oct 22 00:57:31 EEST 2001 \
root@hades.hell.gr:/usr/obj/usr/src/sys/CHARON i386

>Description:

	On a non-acpi aware machine, trying to run acpiconf prints:

		# acpiconf -s1
		acpiconf: No such file or directory

	The attached patch adds the filename of the file that acpiconf
	tried to open to the error message.

		# acpiconf -s1
		acpiconf: /dev/acpi: No such file or directory

>How-To-Repeat:
>Fix:

--- acpiconf.diff begins here ---
Index: acpiconf.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/acpi/acpiconf/acpiconf.c,v
retrieving revision 1.6
diff -2 -u -r1.6 acpiconf.c
--- acpiconf.c	21 Jul 2001 21:51:44 -0000	1.6
+++ acpiconf.c	25 Oct 2001 00:09:41 -0000
@@ -50,5 +50,5 @@
 	fd  = open(ACPIDEV, O_RDWR);
 	if (fd == -1) {
-		err(1, NULL);
+		err(1, ACPIDEV);
 	}
 	if (ioctl(fd, enable, NULL) == -1) {
@@ -67,5 +67,5 @@
 	fd  = open(ACPIDEV, O_RDWR);
 	if (fd == -1) {
-		err(1, NULL);
+		err(1, ACPIDEV);
 	}
 	if (ioctl(fd, ACPIIO_SETSLPSTATE, &sleep_type) == -1) {
--- acpiconf.diff ends here ---
>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@ringlet.net>
To: Giorgos Keramidas <charon@labs.gr>
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)? :)
 
 G'luck,
 Peter
 
 -- 
 You have, of course, just begun reading the sentence that you have just finished reading.

From: "Crist J. Clark" <cristjc@earthlink.net>
To: Peter Pentchev <roam@ringlet.net>
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 <roam@ringlet.net>
 > To: Giorgos Keramidas <charon@labs.gr>
 > 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 <fcntl.h>
  #include <stdio.h>
  #include <sys/ioctl.h>
 +#include <sysexits.h>
  #include <unistd.h>
  
  #include <dev/acpica/acpiio.h>
 @@ -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

From: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To: cjclark@alum.mit.edu, cristjc@earthlink.net
Cc: roam@ringlet.net, freebsd-gnats-submit@FreeBSD.ORG,
	msmith@FreeBSD.ORG, iwasaki@FreeBSD.ORG, iwasaki@jp.FreeBSD.org
Subject: Re: bin/31483: minor correction in error message printed by
 acpiconf.8
Date: Thu, 25 Oct 2001 23:06:15 +0900 (JST)

 Hi,
 
 > >  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,
 
 Thanks taking care of this, I don't mind so please commit :-)
 
 Thanks again

From: Bruce Evans <bde@zeta.org.au>
To: Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
Cc: <freebsd-gnats-submit@FreeBSD.ORG>
Subject: Re: bin/31483: minor correction in error message printed by acpiconf.8
Date: Sat, 27 Oct 2001 19:40:34 +1000 (EST)

 On Thu, 25 Oct 2001, Mitsuru IWASAKI wrote:
 
 > To: cjclark@alum.mit.edu, cristjc@earthlink.net
 >  > 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,
 >
 >  Thanks taking care of this, I don't mind so please commit :-)
 
 Use non-cryptic error messages, not sysexits.h.  sysexits.h is only
 understood by a a couple of programs (mainly sendmail).
 
 Bruce
 
State-Changed-From-To: open->analyzed 
State-Changed-By: cjc 
State-Changed-When: Fri Nov 30 03:35:15 PST 2001 
State-Changed-Why:  
Changes committed to CURRENT. MFC 4 days. 


Responsible-Changed-From-To: freebsd-bugs->cjc 
Responsible-Changed-By: cjc 
Responsible-Changed-When: Fri Nov 30 03:35:15 PST 2001 
Responsible-Changed-Why:  
Made change to CURRENT, waiting for MFC. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31483 
State-Changed-From-To: analyzed->closed 
State-Changed-By: cjc 
State-Changed-When: Fri Nov 30 03:58:45 PST 2001 
State-Changed-Why:  
On second thought, not much reason to wait for the MFC to close this 
since acpiconf(8) doesn't exist in STABLE. (Guess I shouldn't be 
messing with PRs at 4 AM.) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31483 
>Unformatted:
