diff --git a/src/spoof/spoofer.c b/src/spoof/spoofer.c index 6aebc63..f9881ad 100644 --- a/src/spoof/spoofer.c +++ b/src/spoof/spoofer.c @@ -2,6 +2,7 @@ #include #include #include +#include static FILE *(*real_fopen)(const char *path, const char *mode) = NULL; @@ -38,3 +39,19 @@ FILE *fopen(const char *path, const char *mode) { return real_fopen(path, mode); } + +FILE *tmpfile(void) { + char path[] = "./tmpfile_XXXXXX"; + int fd = mkstemp(path); + if (fd == -1) { + fprintf(stderr, "proc_redirect: mkstemp failed\n"); + abort(); + } + fprintf(stderr, "proc_redirect: tmpfile created at %s\n", path); + FILE *f = fdopen(fd, "w+"); + if (!f) { + close(fd); + abort(); + } + return f; +} \ No newline at end of file