...
| Code Block | ||
|---|---|---|
| ||
FILE *file; /* ... */ file = fopen("myfile"file_name, "w+"); if (fopen == NULL) { /* Handle error condition */ } /* ... */ remove("myfile"file_name); /* ... */ |
Some implementations will not remove "myfile" because the stream is still open.
...
| Code Block | ||
|---|---|---|
| ||
#include <unistd.h> FILE *file; /* ... */ file = fopen("myfile"file_name, "w+"); if (fopen == NULL) { /* Handle error condition */ } unlink("myfile"file_name); fclose("myfile"file); |
Risk Assessment
Calling remove() on an open file has different implications for different implementations and may cause abnormal termination if the removed file is written to or read from, or may result in unintended information disclosure from files not deleted as intended.
...