Your message dated Sat, 3 Dec 2011 14:05:29 +0100
with message-id <[email protected]>
and subject line Already fixed, needs upload
has caused the Debian Bug report #646522,
regarding powertop: Crashes if /boot/config-* has more than 5000 lines
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
646522: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646522
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: powertop
Version: 1.11-1
Severity: serious
File: /usr/sbin/powertop

Dear mainteners,

The powertop command crashes if there are more than 5000 lines in the
kernel configuration file located in /boot/config-*, or if there is a
line longer than 100 characters (for info, the kernel 2.6.32-5-amd64 in
backport has a config file containing 5415 lines, the longest of 162
characters).

This crash comes from the static and fixed-size array defined in
config.c. This has not been fixed in the latest version of powertop that
seems to be available (1.12).

I attach an (still atrocious) patched version of config.c that should
not crash for a few releases of the kernel.

Cheers,

/*
 * Copyright 2007, Intel Corporation
 *
 * This file is part of PowerTOP
 *
 * This program file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program in a file named COPYING; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authors:
 * 	Arjan van de Ven <[email protected]>
 */

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include <dirent.h>

#include "powertop.h"

#define NB_CONFIG_LINES_MAX 10000
#define STRING_BUFFER_SIZE 256

/* static arrays are not nice programming.. but they're easy */
static char configlines[NB_CONFIG_LINES_MAX][STRING_BUFFER_SIZE];
static int configcount;

static void read_kernel_config(void)
{
	FILE *file;
	char version[STRING_BUFFER_SIZE], *c;
	char filename[STRING_BUFFER_SIZE];
	if (configcount)
		return;
	if (access("/proc/config.gz", R_OK) == 0) {
		file = popen("zcat /proc/config.gz 2> /dev/null", "r");
		while (file && !feof(file)) {
			char line[STRING_BUFFER_SIZE];
			if (fgets(line, STRING_BUFFER_SIZE, file) == NULL)
				break;
			strcpy(configlines[configcount++], line);
		}
		pclose(file);
		return;
	}
	file = fopen("/proc/sys/kernel/osrelease", "r");
	if (!file)
		return;
	if (fgets(version, STRING_BUFFER_SIZE, file) == NULL) {
		fclose(file);
		return;
	}
	fclose(file);
	c = strchr(version, '\n');
	if (c)
		*c = 0;
	sprintf(filename, "/boot/config-%s", version);
	file = fopen(filename, "r");
	if (!file) {
		sprintf(filename, "/lib/modules/%s/build/.config", version);
		file = fopen(filename, "r");
	}
	if (!file)
		return;
	while (!feof(file)) {
		char line[STRING_BUFFER_SIZE];
		if (fgets(line, STRING_BUFFER_SIZE, file) == NULL)
			break;
		strcpy(configlines[configcount++], line);
	}
	fclose(file);
}

/*
 * Suggest the user to turn on/off a kernel config option.
 * "comment" gets displayed if it's not already set to the right value 
 */
void suggest_kernel_config(char *string, int onoff, char *comment, int weight)
{
	int i;
	char searchon[STRING_BUFFER_SIZE];
	char searchoff[STRING_BUFFER_SIZE];
	int found = 0;

	read_kernel_config();

	sprintf(searchon, "%s=", string);
	sprintf(searchoff, "# %s is not set", string);

	for (i = 0; i < configcount; i++) {
		if (onoff && strstr(configlines[i], searchon))
			return;
		if (onoff==0 && strstr(configlines[i], searchoff))
			return;
		if (onoff==0 && strstr(configlines[i], searchon))
			found = 1;
	}
	if (onoff || found)
		add_suggestion(comment, weight, 0, NULL, NULL);
	fflush(stdout);
}
-- System Information:
Debian Release: 6.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

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

Versions of packages powertop depends on:
ii  libc6                     2.11.2-10      Embedded 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:
pn  cpufrequtils                  <none>     (no description available)
pn  laptop-mode-tools             <none>     (no description available)

-- no debconf information

-- 
Francois Fleuret                         http://www.idiap.ch/~fleuret/

--- End Message ---
--- Begin Message ---
Version: 1.13-1
thanks

This bug affetcs squeeze only and has already been fixed in #589438. Okay, the
fix only increases the static array size from 5000 to 10000, but that seems to
be enough for the old bug report. Luckily, wheezy already has the new 1.97 (pre
2.0) version which has a totally different codebase which does not contain this
bug.

Mail sent from the BSP in Hildesheim :)

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |


--- End Message ---

Reply via email to