...
In this compliant solution, mkostemp is used instead.
Code Block | ||||
---|---|---|---|---|
| ||||
static const char temp_file_template[] = TEMP_DIR DIR_SEPARATOR "xyzzy_XXXXXX"; char file_name[sizeof(temp_file_template)]; FILE *fp; int fd; strcpy_s(file_name, sizeof(temp_file_template), temp_file_template); fd = mkostemp(file_name, O_RDWR | O_CREAT | O_TRUNC); if (fd == -1) { /* Handle error */ } fp = fdopen(fd, "wb+"); if (fp == NULL) { /* Handle error */ } |
Noncompliant Code Example
...