[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wondering about -Wstack-protector



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