Subject: pkg/14550: asapm doesn't work with `new' apm
To: None <gnats-bugs@gnats.netbsd.org>
From: None <lha@stacken.kth.se>
List: netbsd-bugs
Date: 11/12/2001 12:47:27
>Number:         14550
>Category:       pkg
>Synopsis:       asapm doesn't work with `new' apm
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 12 03:48:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Love
>Release:        NetBSD 1.5Y
>Organization:
	Stacken Computer Club
>Environment:
System: NetBSD nutcracker.stacken.kth.se 1.5Y NetBSD 1.5Y (NUTCRACKER) #0: Thu Nov 8 10:01:57 CET 2001 lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/NUTCRACKER i386
Architecture: i386
Machine: i386
>Description:

	Since apm got support for probing individual batteries asapm
	doesn't work. This is since the apm_info structure isn't
	initialized before the ioctl() is done.
	
>How-To-Repeat:

	Compile asapm and try to use it.

>Fix:

I've sent a mail to the asapm maintainer.

: lha@nutcracker ; pwd
/usr/pkgsrc/sysutils/asapm
: root@nutcracker ; cvs diff -N
? work.i386
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/asapm/distinfo,v
retrieving revision 1.3
diff -w -u -r1.3 distinfo
--- distinfo	2001/07/15 10:50:07	1.3
+++ distinfo	2001/11/12 11:37:06
@@ -4,3 +4,4 @@
 Size (asapm-2.10.tar.gz) = 51304 bytes
 SHA1 (patch-aa) = 570d2240f6afbf78d3cd72e1c1b963beb7ae074d
 SHA1 (patch-ab) = 8796f1f6220ecdbd23d360bb18f721e1ef83febf
+SHA1 (patch-ac) = c7d581dabe58cdf1773aa0b41d9bd3c575d3cf1c
Index: patches/patch-ac
===================================================================
RCS file: patch-ac
diff -N patch-ac
--- /dev/null	Sun May 20 17:40:04 2001
+++ patch-ac	Mon Nov 12 03:37:06 2001
@@ -0,0 +1,34 @@
+$NetBSD$
+
+--- apm_read.c.foo	Mon May 31 13:47:49 1999
++++ apm_read.c	Mon Nov 12 12:33:49 2001
+@@ -98,12 +98,14 @@
+ {
+ 	int fd;
+ 	struct apm_info info;
++	memset(&info, 0, sizeof(info));
+ 	if ((fd = open(apm_device_file, O_RDONLY)) == -1) {
+ 		error_handle(1, "");
+ 		return;
+ 	}
+ 	if (ioctl(fd, APMIO_GETINFO, &info) == -1) {
+ 		error_handle(4, "");
++		close(fd);
+ 		return;
+ 	}
+ 	close(fd);
+@@ -138,12 +140,14 @@
+ {
+ 	int fd;
+ 	struct apm_power_info info;
++	memset(&info, 0, sizeof(info));
+ 	if ((fd = open(apm_device_file, O_RDONLY)) == -1) {
+ 		error_handle(1, "");
+ 		return;
+ 	}
+ 	if (ioctl(fd, APM_IOC_GETPOWER, &info) == -1) {
+ 		error_handle(4, "");
++		close(fd);
+ 		return;
+ 	}
+ 	close(fd);




>Release-Note:
>Audit-Trail:
>Unformatted: