Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Oct 2001 04:50:04 -0700 (PDT)
From:      "Crist J. Clark" <cristjc@earthlink.net>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/31483: minor correction in error message printed by acpiconf.8
Message-ID:  <200110251150.f9PBo4G83042@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/31483; it has been noted by GNATS.

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

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110251150.f9PBo4G83042>