Description of problem: File "POO" does not exist #include <stdio.h> int main ( int argc, char **argv ) { FILE *foo; foo = fopen ( "POO", "r" ); fclose ( foo ); return 0; } Version-Release number of selected component (if applicable): 2.14.90-24.fc16.6 How reproducible: 100 % Steps to Reproduce: 1. Run the program listed above. 2. See the segmentation fault 3. Be sad. Actual results: Segmentation fault Expected results: Error EBADF returned Additional info:
GLIBC's behaviour is valid according to ISO C standard 7.1.4. "If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or a null pointer... the behaviour is undefined". The rationale behind this is it's generally impossible to determine if a particular pointer value is a valid pointer and points to memory of the correct data type. Clearly you need to be checking the result of your fopen call to ensure it's non-null.