summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-06-01 11:12:48 +0000
committerYann Ylavic <ylavic@apache.org>2020-06-01 11:12:48 +0000
commit9c805a30a4469e27e7f239509fdb79ed1b59fb3c (patch)
treea2e55530e50c55fa197b9d2fc807136e4e8a8609
parent24555786a7c2d3cf96fb8cfdf63dd981c2744cea (diff)
downloadapr-9c805a30a4469e27e7f239509fdb79ed1b59fb3c.tar.gz
Merge r1878279 from trunk:
apr_file_mktemp: clear APR_FOPEN_NOCLEANUP if not requested. apr_os_file_put() adds no cleanup so it forces APR_FOPEN_NOCLEANUP, but when apr_file_mktemp() adds the cleanup implicitely (unless the user specifies APR_FOPEN_NOCLEANUP explicitely), it needs to clear APR_FOPEN_NOCLEANUP for the resulting file. Note: Without this fix, a file created with apr_file_mktemp() and later passed to apr_file_setaside(), or within a file bucket passed to apr_bucket_setaside(), will leak both the fd and inode because the cleanup gets dropped (e.g. httpd's BZ 64452). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1878355 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/unix/mktemp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/file_io/unix/mktemp.c b/file_io/unix/mktemp.c
index 7530a2510..30bc78ff5 100644
--- a/file_io/unix/mktemp.c
+++ b/file_io/unix/mktemp.c
@@ -216,7 +216,10 @@ APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_i
apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
apr_unix_file_cleanup,
apr_unix_child_file_cleanup);
- }
+
+ /* Clear APR_FOPEN_NOCLEANUP set by apr_os_file_put() */
+ (*fp)->flags &= ~APR_FOPEN_NOCLEANUP;
+ }
#endif
return APR_SUCCESS;
}