[Pkg-acpi-devel] Bug#542114: acpitool: Segfault with -b/-B options

Bernardo Dal Seno dibbex at gmail.com
Fri Apr 23 23:23:28 UTC 2010


Package: acpitool
Version: 0.5.1-1
Severity: normal
Tags: patch


Running acpitool with options `-b' or `-B' causes a segfault:

> acpitool -v -b
Segmentation fault

Backtrace from gdb:

(gdb) run -b
Starting program: /usr/bin/acpitool -b

Program received signal SIGSEGV, Segmentation fault.
0xb7d92f8a in _IO_vfscanf () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0  0xb7d92f8a in _IO_vfscanf () from /lib/i686/cmov/libc.so.6
#1  0xb7da68f1 in vsscanf () from /lib/i686/cmov/libc.so.6
#2  0xb7d964cb in sscanf () from /lib/i686/cmov/libc.so.6
#3  0x080590d7 in Get_Battery_Info_from_Sys (bat_nr=1, batt_info=0x8061008, 
    verbose=0) at battery.cpp:658
#4  0x0805a6d6 in Do_Battery_Stuff (show_empty=0, info_level=0, verbose=0)
    at battery.cpp:119
#5  0x0804e99e in Print_ACPI_Info (show_ac=0, show_therm=0, show_trip=0, 
    show_fan=0, show_batteries=1, show_empty=0, show_version=0, show_cpu=0, 
    show_wake=0, e_set=0, info_level=0, verbose=0) at acpitool.cpp:117
#6  0x0804a3b0 in main (argc=2, argv=0xbffffac4) at main.cpp:229

The mentioned sscanf() call has an incorrect format string, as there are 
asterisks missing.  This fixes it:
-------CUT-------
--- src/battery.cpp~    2010-04-24 00:56:07.000000000 +0200
+++ src/battery.cpp     2010-04-24 01:03:33.000000000 +0200
@@ -654,8 +654,8 @@
                memset(attr, '\0', 100);
                memset(temp, '\0', 100);
                fgets(str, 100, power_fp);
-               sscanf(str, "%[^=]s %*s %[^\n]", attr);
-               sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+               sscanf(str, "%[^=]s %*s %*[^\n]", attr);
+               sscanf(str, "%*[^=] %*c %s %*[^\n]",temp); 
                if (strcmp(attr,"POWER_SUPPLY_STATUS")==0) {
                        strncpy(batt_info->Charging_State, temp, 12);
                }   
-------CUT-------

Best regards,
Bernardo

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-4-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages acpitool depends on:
ii  libc6                         2.10.2-6   Embedded GNU C Library: Shared lib
ii  libgcc1                       1:4.4.3-9  GCC support library
ii  libstdc++6                    4.4.3-9    The GNU Standard C++ Library v3

Versions of packages acpitool recommends:
ii  acpid                         1:2.0.3-1  Advanced Configuration and Power I

acpitool suggests no packages.

-- debconf-show failed
-------------- next part --------------
--- src/battery.cpp~	2010-04-24 00:56:07.000000000 +0200
+++ src/battery.cpp	2010-04-24 01:03:33.000000000 +0200
@@ -654,8 +654,8 @@
 		memset(attr, '\0', 100);
     		memset(temp, '\0', 100);
 		fgets(str, 100, power_fp);
-		sscanf(str, "%[^=]s %*s %[^\n]", attr);
-    		sscanf(str, "%*[^=] %*c %s %[^\n]",temp); 
+		sscanf(str, "%[^=]s %*s %*[^\n]", attr);
+    		sscanf(str, "%*[^=] %*c %s %*[^\n]",temp); 
 		if (strcmp(attr,"POWER_SUPPLY_STATUS")==0) {
     			strncpy(batt_info->Charging_State, temp, 12);
     		}   


More information about the Pkg-acpi-devel mailing list