The rename()
function has the following prototype.
Code Block |
---|
int rename(char const char *old, char const char *new); |
If the file referenced by new
exists prior to calling rename()
, the behavior is implementation-defined. For portability, you must ensure that the file referenced by new
does not exist when rename()
is invoked.
...
Code Block | ||
---|---|---|
| ||
/* program code */ char const char *old = "oldfile.ext"; char const char *new = "newfile.ext"; if (rename(old, new) != 0) { /* Handle rename failure */ } /* program code */ |
...
Code Block | ||
---|---|---|
| ||
/* program code */ char const char *old = "oldfile.ext"; char const char *new = "newfile.ext"; FILE *file = fopen(new, "r"); if (!file) { if (rename(old, new) != 0) { /* Handle rename failure */ } } else { fclose(file); /* handle error condition */ } /* program code */ |
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FIO10-A | 2 ( medium ) 2 ( | probable ) | 2 ( medium ) | P8 | L2 |
Related Vulnerabilities
...