[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wondering about -Wstack-protector
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: Re: Wondering about -Wstack-protector
- From: Han Boetes <han_(_at_)_mijncomputer_(_dot_)_nl>
- Date: Fri, 8 Apr 2005 00:57:10 +0200
- Mail-followup-to: misc_(_at_)_openbsd_(_dot_)_org
Pretty easy; it doesn't protect pointerarrays.
% cat test.c
/* test-propolice.c */
#define OVERFLOW "This is longer than 10 bytes"
#include <string.h>
int
main (int argc, char *argv[]) {
char buffer[10];
strcpy(buffer, OVERFLOW);
return 0;
}
% gcc -fstack-protector -Wall -Wstack-protector test.c
% cat test2.c
/* test-propolice.c */
#define OVERFLOW "This is longer than 10 bytes"
#include <string.h>
int
main (int argc, char *argv[]) {
char buffer[10];
char *buffer2;
strcpy(buffer, OVERFLOW);
strcpy(buffer2, OVERFLOW);
return 0;
}
% gcc -fstack-protector -Wall -Wstack-protector test2.c
test2.c: In function `main':
test2.c:12: warning: not protecting variables: it has a variable
length buffer
And since pointerarrays are used all over the place the relative
value of the warning is next to nothing.
# Han
Visit your host, monkey.org