Commit 77bc182a authored by Jeff Trawick's avatar Jeff Trawick
Browse files

Fix a problem in mod_mime_magic where file descriptor 2 would be

inadvertently closed.  This logic was in the uncompress child in 1.3
but was in the parent in 2.0.

uncompress_child() was renamed to create_uncompress_child() to reflect
a change in use since 1.3.

A note was added about missing 1.3 logic for doing something with the
stderr of the uncompress process.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88538 13f79535-47bb-0310-9956-ffa450edef68
parent 55449a12
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.15-dev

  *) Get rid of an inadvertent close of file descriptor 2 in
     mod_mime_magic.  [Greg Ames, Jeff Trawick]

  *) Add a hook, create_request.  This hook allows modules to modify
     a request while it is being created.  This hook is called for all
     request_rec's, main request, sub request, and internal redirect.
+9 −7
Original line number Diff line number Diff line
@@ -2147,7 +2147,7 @@ struct uncompress_parms {
    int method;
};

static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
static int create_uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
                                   apr_file_t **pipe_in)
{
    int rc = 1;
@@ -2158,6 +2158,12 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
    apr_procattr_t *procattr;
    apr_proc_t *procnew;

    /* XXX missing 1.3 logic: 
     *
     * what happens when !compr[parm->method].silent?
     * Should we create the err pipe, read it, and copy to the log?
     */
        
    env = (const char *const *)ap_create_environment(child_context, r->subprocess_env);

    if ((apr_procattr_create(&procattr, child_context) != APR_SUCCESS) ||
@@ -2175,10 +2181,6 @@ static int uncompress_child(struct uncompress_parms *parm, apr_pool_t *cntxt,
        new_argv[2] = r->filename;
        new_argv[3] = NULL;

        if (compr[parm->method].silent) {
            close(STDERR_FILENO);
        }

        procnew = apr_pcalloc(child_context, sizeof(*procnew));
        rc = apr_proc_create(procnew, compr[parm->method].argv[0],
                               new_argv, env, procattr, child_context);
@@ -2216,7 +2218,7 @@ static int uncompress(request_rec *r, int method,
    if (apr_pool_create(&sub_context, r->pool) != APR_SUCCESS)
        return -1;

    if ((rv = uncompress_child(&parm, sub_context, &pipe_out)) != APR_SUCCESS) {
    if ((rv = create_uncompress_child(&parm, sub_context, &pipe_out)) != APR_SUCCESS) {
	ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
		    MODNAME ": couldn't spawn uncompress process: %s", r->uri);
	return -1;