diff --git a/plugins/fastrouter/fastrouter.c b/plugins/fastrouter/fastrouter.c index 42e4d5a2..7635b7e8 100644 --- a/plugins/fastrouter/fastrouter.c +++ b/plugins/fastrouter/fastrouter.c @@ -595,7 +595,7 @@ void fastrouter_loop(int id) { if (ufr.post_buffering > 0 && fr_session->post_cl > ufr.post_buffering) { fr_session->status = FASTROUTER_STATUS_BUFFERING; - fr_session->buf_file_name = tempnam(ufr.pb_base_dir, "uwsgi"); + fr_session->buf_file_name = uwsgi_tmpname(ufr.pb_base_dir, "uwsgiXXXXX"); if (!fr_session->buf_file_name) { uwsgi_error("tempnam()"); close_session(fr_session); diff --git a/utils.c b/utils.c index 45a5e506..b2598542 100644 --- a/utils.c +++ b/utils.c @@ -3760,3 +3760,13 @@ void uwsgi_add_app(int id, uint8_t modifier1, char *mountpoint, int mountpoint_l } } + +char *uwsgi_tmpname(char *base, char *id) { + char *template = uwsgi_concat3(base, "/", id); + if (mkstemp(template) < 0) { + free(template); + return NULL; + } + + return template; +} diff --git a/uwsgi.h b/uwsgi.h index bf8ae6cc..8197bc71 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -2554,6 +2554,8 @@ void uwsgi_opt_set_cap(char *, char *, void *); void uwsgi_opt_set_unshare(char *, char *, void *); #endif +char *uwsgi_tmpname(char *, char *); + #ifdef UWSGI_AS_SHARED_LIBRARY int uwsgi_init(int, char **, char **);