You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2020/06/01 11:12:48 UTC

svn commit: r1878355 - in /apr/apr/branches/1.7.x: ./ file_io/unix/mktemp.c

Author: ylavic
Date: Mon Jun  1 11:12:48 2020
New Revision: 1878355

URL: http://svn.apache.org/viewvc?rev=1878355&view=rev
Log:
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).

Modified:
    apr/apr/branches/1.7.x/   (props changed)
    apr/apr/branches/1.7.x/file_io/unix/mktemp.c

Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1878279

Modified: apr/apr/branches/1.7.x/file_io/unix/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/file_io/unix/mktemp.c?rev=1878355&r1=1878354&r2=1878355&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/file_io/unix/mktemp.c (original)
+++ apr/apr/branches/1.7.x/file_io/unix/mktemp.c Mon Jun  1 11:12:48 2020
@@ -216,7 +216,10 @@ APR_DECLARE(apr_status_t) apr_file_mktem
         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;
 }