Skip to contentSkip to conversation

perf, ui: Eliminate stack-smashing protection compiler complain

PATCH In review Cyrill Gorcunov 2 participants 3 messages Nov 6, 2010 – Nov 7, 2010 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf, ui: Eliminate stack-smashing protection compiler complain

The gcc complains on Yes, No being allocated from stack space. Make
them conts to feel compiler happy.

 |    CC util/ui/util.o
 | cc1: warnings being treated as errors
 | util/ui/util.c: In function ‘ui__dialog_yesno’:
 | util/ui/util.c:108: error: not protecting function: no buffer at least 8 bytes long
 | make: *** [util/ui/util.o] Error 1
CC Arnaldo Carvalho de Melo <[email protected]>
CC Frédéric Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>

---

Since it seems only me who has such error I presume ssp-buffer-size=8 set for mine local version of gcc (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4))

 tools/perf/util/ui/util.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/util/ui/util.c +3 -2
Index: linux-2.6.git/tools/perf/util/ui/util.c
=====================================================================
@@ -104,9 +104,10 @@ out_destroy_form:
 	return rc;
 }
 
+static const char yes[] = "Yes", no[] = "No";
+
 bool ui__dialog_yesno(const char *msg)
 {
 	/* newtWinChoice should really be accepting const char pointers... */
-	char yes[] = "Yes", no[] = "No";
-	return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
+	return newtWinChoice(NULL, (char *)yes, (char *)no, (char *)msg) == 1;
 }
#1 lore raw
Quoted 9 lines · Cyrill Gorcunov

The gcc complains on Yes, No being allocated from stack space. Make
them conts to feel compiler happy.

 |    CC util/ui/util.o
 | cc1: warnings being treated as errors
 | util/ui/util.c: In function ‘ui__dialog_yesno’:
 | util/ui/util.c:108: error: not protecting function: no buffer at least 8 bytes long
 | make: *** [util/ui/util.o] Error 1
Quoted 5 lines
CC Arnaldo Carvalho de Melo <[email protected]>
CC Frédéric Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>

---

I hope we can finally queue this one fix, the warning is there for a while now, and this patch looks quite sensible :)

Quoted 23 lines

Since it seems only me who has such error I presume ssp-buffer-size=8 set for mine local version of gcc (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4))

 tools/perf/util/ui/util.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-2.6.git/tools/perf/util/ui/util.c
=====================================================================

tools/perf/util/ui/util.c +2 -2
@@ -104,9 +104,10 @@ out_destroy_form:
 	return rc;
 }
 
+static const char yes[] = "Yes", no[] = "No";
 bool ui__dialog_yesno(const char *msg)
 {
 	/* newtWinChoice should really be accepting const char pointers... */
-	char yes[] = "Yes", no[] = "No";
-	return newtWinChoice(NULL, yes, no, (char *)msg) == 1;
+	return newtWinChoice(NULL, (char *)yes, (char *)no, (char *)msg) == 1;
 }
#2 lore raw
Quoted 10 lines · Frederic Weisbecker
Quoted 9 lines · Cyrill Gorcunov

The gcc complains on Yes, No being allocated from stack space. Make
them conts to feel compiler happy.

 |    CC util/ui/util.o
 | cc1: warnings being treated as errors
 | util/ui/util.c: In function ‘ui__dialog_yesno’:
 | util/ui/util.c:108: error: not protecting function: no buffer at least 8 bytes long
 | make: *** [util/ui/util.o] Error 1
Quoted 9 lines
Quoted 5 lines
CC Arnaldo Carvalho de Melo <[email protected]>
CC Frédéric Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>

---

I hope we can finally queue this one fix, the warning is there for a while now, and this patch looks quite sensible :)

yup, thanks for review ;)