Hey, > Impressive design. What would happen if it skips half of the "config"? I > agree that not segfaulting is incredibly better than segfaulting, but like > this the remaining bunch of lines will be silently ignored? I've rewritten the patch from Mel Gorman, now you'll get a printf output on the console if the config file is too large (and powertop will abort). Please have a look on the updated debdiff attached to this mail.
Greetings Winnie
diff -u powertop-1.11/debian/changelog powertop-1.11/debian/changelog --- powertop-1.11/debian/changelog +++ powertop-1.11/debian/changelog @@ -1,3 +1,10 @@ +powertop (1.11-1+squeeze1) stable; urgency=low + + * Fix segfault on newer kernels with large config files. + Thanks to Mel Gorman (Closes: #610101) + + -- Patrick Winnertz <[email protected]> Fri, 11 Mar 2011 11:22:33 +0100 + powertop (1.11-1) unstable; urgency=low * New upstream release diff -u powertop-1.11/debian/patches/00list powertop-1.11/debian/patches/00list --- powertop-1.11/debian/patches/00list +++ powertop-1.11/debian/patches/00list @@ -1,0 +2 @@ +increase-configlimit.dpatch only in patch2: unchanged: --- powertop-1.11.orig/debian/patches/increase-configlimit.dpatch +++ powertop-1.11/debian/patches/increase-configlimit.dpatch @@ -0,0 +1,59 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## increase-configlimit.patch.dpatch by <[email protected]> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' powertop-1.11~/config.c powertop-1.11/config.c +--- powertop-1.11~/config.c 2011-03-11 19:06:28.000000000 +0100 ++++ powertop-1.11/config.c 2011-03-17 13:23:23.969122826 +0100 +@@ -33,9 +33,14 @@ + #include "powertop.h" + + /* static arrays are not nice programming.. but they're easy */ +-static char configlines[5000][100]; ++static char configlines[MAXCONFIGLINES][100]; + static int configcount; + ++static void cleanup_curses_w_errormsg(void) { ++ endwin(); ++ printf(_("Your kernel config exceeds the limit of %i lines, aborting!\n"),MAXCONFIGLINES); ++} ++ + static void read_kernel_config(void) + { + FILE *file; +@@ -49,6 +54,10 @@ + char line[100]; + if (fgets(line, 100, file) == NULL) + break; ++ if (configcount >= MAXCONFIGLINES) { ++ atexit(cleanup_curses_w_errormsg); ++ exit(EXIT_FAILURE); ++ } + strcpy(configlines[configcount++], line); + } + pclose(file); +@@ -77,6 +86,10 @@ + char line[100]; + if (fgets(line, 100, file) == NULL) + break; ++ if (configcount >= MAXCONFIGLINES) { ++ atexit(cleanup_curses_w_errormsg); ++ exit(EXIT_FAILURE); ++ } + strcpy(configlines[configcount++], line); + } + fclose(file); +diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' powertop-1.11~/powertop.h powertop-1.11/powertop.h +--- powertop-1.11~/powertop.h 2008-12-30 19:52:54.000000000 +0100 ++++ powertop-1.11/powertop.h 2011-03-17 13:23:35.981182381 +0100 +@@ -88,6 +88,7 @@ + + #define _(STRING) gettext(STRING) + ++#define MAXCONFIGLINES 10000 + + #define PT_COLOR_DEFAULT 1 + #define PT_COLOR_HEADER_BAR 2

