Bug#665695: powertop: segmentation fault at read_kernel_config() when calling strcpy()

2012-03-25 Thread Németh Márton
Patch taken from upstream powertop 1.13 is attached which solves this problem.
--- powertop-1.11/config.c	2008-12-30 19:52:54.0 +0100
+++ powertop-1.13/config.c	2010-07-20 01:08:21.0 +0200
@@ -33,7 +33,8 @@
 #include "powertop.h"
 
 /* static arrays are not nice programming.. but they're easy */
-static char configlines[5000][100];
+#define MAXCONFIGLINES 1
+static char configlines[MAXCONFIGLINES][100];
 static int configcount;
 
 static void read_kernel_config(void)
@@ -49,6 +50,8 @@
 			char line[100];
 			if (fgets(line, 100, file) == NULL)
 break;
+			if (configcount >= MAXCONFIGLINES)
+break;
 			strcpy(configlines[configcount++], line);
 		}
 		pclose(file);
@@ -77,6 +80,8 @@
 		char line[100];
 		if (fgets(line, 100, file) == NULL)
 			break;
+		if (configcount >= MAXCONFIGLINES)
+			break;
 		strcpy(configlines[configcount++], line);
 	}
 	fclose(file);


Bug#665695: powertop: segmentation fault at read_kernel_config() when calling strcpy()

2012-03-25 Thread Márton Németh
Package: powertop
Version: 1.11-1
Severity: important
Tags: patch upstream

powertop 1.11 crashes after first displaing the list of processes with 
segmentation fault.

I have also tested upstream versions:

http://www.lesswatts.org/projects/powertop/download/powertop-1.12.tar.gz -> 
also crashes
http://www.lesswatts.org/projects/powertop/download/powertop-1.13.tar.gz -> 
works fine

Here is the output of gdb backtrace when the powertop source was downloaded 
with "apt-get source powertop" and recompiled in order to include debug symbols:

Program received signal SIGSEGV, Segmentation fault.
0xb7e9a704 in strcpy () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
(gdb) bt
#0  0xb7e9a704 in strcpy () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
#1  0x0804cf30 in read_kernel_config (string=0xbfffe83c 
"CONFIG_COMEDI_NI_6527=m\n", onoff=1, 
comment=0xb7fdeab2 "Tanács: Engedélyezd a CONFIG_USB_SUSPEND kernel 
konfigurációs opciót.\nEz az opció automatikusan kikapcsolja az USB-t ha nincs 
használatban, \nezzel körülbelül 1 Watt energiát takarít meg.", weight=20) at 
config.c:80
#2  suggest_kernel_config (string=0xbfffe83c "CONFIG_COMEDI_NI_6527=m\n", 
onoff=1, 
comment=0xb7fdeab2 "Tanács: Engedélyezd a CONFIG_USB_SUSPEND kernel 
konfigurációs opciót.\nEz az opció automatikusan kikapcsolja az USB-t ha nincs 
használatban, \nezzel körülbelül 1 Watt energiát takarít meg.", weight=20) at 
config.c:96
#3  0x0804c6fb in main (argc=1, argv=0xb4d4) at powertop.c:1063
(gdb) q
A debugging session is active.

Inferior 1 [process 4277] will be killed.

Quit anyway? (y or n) y
/tmp/src/powertop/powertop-1.11# ./powertop  --version
powertop version 1.11
/tmp/src/powertop/powertop-1.11# /usr/sbin/powertop --version
powertop version 1.11
/tmp/src/powertop/powertop-1.11# locale
LANG=hu_HU.UTF-8
LANGUAGE=
LC_CTYPE="hu_HU.UTF-8"
LC_NUMERIC="hu_HU.UTF-8"
LC_TIME="hu_HU.UTF-8"
LC_COLLATE="hu_HU.UTF-8"
LC_MONETARY="hu_HU.UTF-8"
LC_MESSAGES="hu_HU.UTF-8"
LC_PAPER="hu_HU.UTF-8"
LC_NAME="hu_HU.UTF-8"
LC_ADDRESS="hu_HU.UTF-8"
LC_TELEPHONE="hu_HU.UTF-8"
LC_MEASUREMENT="hu_HU.UTF-8"
LC_IDENTIFICATION="hu_HU.UTF-8"
LC_ALL=
 

-- System Information:
Debian Release: 6.0.4
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.1.0-1-686-pae (SMP w/1 CPU core)
Locale: LANG=hu_HU.UTF-8, LC_CTYPE=hu_HU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages powertop depends on:
ii  libc6 2.13-24Embedded GNU C Library: Shared lib
ii  libncursesw5  5.7+20100313-5 shared libraries for terminal hand

powertop recommends no packages.

Versions of packages powertop suggests:
ii  cpufrequtils  007-1+squeeze1 utilities to deal with the cpufreq
pn  laptop-mode-tools  (no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org