| 1 |
/* C only: C++ FE fpermissive already emits an error for initializer |
| 2 |
string too long. |
| 3 |
C++ compatible parts have been moved into c-c++-common/analyzer/fopen-2.c */ |
| 4 |
|
| 5 |
typedef struct FILE FILE; |
| 6 |
FILE *fopen (const char *pathname, const char *mode); |
| 7 |
|
| 8 |
FILE * |
| 9 |
test_unterminated_pathname (const char *mode) |
| 10 |
{ |
| 11 |
char buf[3] = "abc"; |
| 12 |
return fopen (buf, mode); /* { dg-warning "stack-based buffer over-read" } */ |
| 13 |
/* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of 'fopen'..." "event" { target *-*-* } .-1 } */ |
| 14 |
} |
| 15 |
|
| 16 |
FILE * |
| 17 |
test_unterminated_mode (const char *filename) |
| 18 |
{ |
| 19 |
char buf[3] = "abc"; |
| 20 |
return fopen (filename, buf); /* { dg-warning "stack-based buffer over-read" } */ |
| 21 |
/* { dg-message "while looking for null terminator for argument 2 \\('&buf'\\) of 'fopen'..." "event" { target *-*-* } .-1 } */ |
| 22 |
} |