Hello,

powertop uses strcpy to copy values to status_bar_slots[9], which are too 
long. E.g. " A - AC97 Stromsparfunktionen einschalten" which need 41 
characters in C but by default status_bar_slots[9] is only 40 characters big. 
My original Fedora bugzilla with a little more information report is here:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=246796

Regards,
Till
diff -u powertop-1.7.orig/display.c powertop-1.7/display.c
--- powertop-1.7.orig/display.c	2007-06-18 03:16:33.000000000 +0200
+++ powertop-1.7/display.c	2007-07-05 02:43:51.000000000 +0200
@@ -44,7 +44,7 @@
 static WINDOW *status_bar_window;
 
 
-char status_bar_slots[10][40];
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
 
 static void cleanup_curses(void) {
 	endwin();
@@ -104,8 +104,8 @@
 	suggestion_window = subwin(stdscr, 3, maxx, maxy-4, 0);	
 	status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0);
 
-	strcpy(status_bar_slots[0], _(" Q - Quit "));
-	strcpy(status_bar_slots[1], _(" R - Refresh "));
+	strncpy(status_bar_slots[0], _(" Q - Quit "), STATUS_BAR_SLOTSIZE);
+	strncpy(status_bar_slots[1], _(" R - Refresh "), STATUS_BAR_SLOTSIZE);
 
 	werase(stdscr);
 	refresh();
@@ -148,7 +148,7 @@
 	werase(status_bar_window);
 
 	x = 0;
-	for (i=0; i<10; i++) {
+	for (i=0; i < STATUS_BAR_NR_SLOTS; i++) {
 		if (strlen(status_bar_slots[i])==0)
 			continue;
 		wattron(status_bar_window, A_REVERSE);
Gemeinsame Unterverzeichnisse: powertop-1.7.orig/po und powertop-1.7/po.
diff -u powertop-1.7.orig/powertop.h powertop-1.7/powertop.h
--- powertop-1.7.orig/powertop.h	2007-06-17 08:21:37.000000000 +0200
+++ powertop-1.7/powertop.h	2007-07-05 02:39:53.000000000 +0200
@@ -64,7 +64,10 @@
 extern int topcstate;
 extern int topfreq;  
 
-extern char status_bar_slots[10][40];
+#define STATUS_BAR_NR_SLOTS 10
+#define STATUS_BAR_SLOTSIZE 40 
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
+
 extern char suggestion_key;
 extern suggestion_func *suggestion_activate; 
 
diff -u powertop-1.7.orig/suggestions.c powertop-1.7/suggestions.c
--- powertop-1.7.orig/suggestions.c	2007-06-08 07:33:13.000000000 +0200
+++ powertop-1.7/suggestions.c	2007-07-05 02:42:59.000000000 +0200
@@ -70,7 +70,7 @@
 		ptr = next;
 	}
 	suggestions = NULL;
-	strcpy(status_bar_slots[9],"");
+	strncpy(status_bar_slots[9], "", STATUS_BAR_SLOTSIZE);
 	suggestion_key = 255;
 	suggestion_activate = NULL;
 	total_weight = 0;
@@ -103,7 +103,7 @@
 	int value, running = 0;
 	struct suggestion *ptr;
 
-	strcpy(status_bar_slots[9],"");
+	strncpy(status_bar_slots[9], "", STATUS_BAR_SLOTSIZE);
 	suggestion_key = 255;
 	suggestion_activate = NULL;
 
@@ -119,7 +119,7 @@
 		running += ptr->weight;
 		if (running > value) {
 			if (ptr->keystring)
-				strcpy(status_bar_slots[9],ptr->keystring);
+	                        strncpy(status_bar_slots[9], ptr->keystring, STATUS_BAR_SLOTSIZE);
 			suggestion_key = ptr->key;
 			suggestion_activate = ptr->func;
 			show_suggestion(ptr->string);
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power

Reply via email to