| 2165 | } |
| 2166 | |
| 2167 | static int uncompress(request_rec *r, int method, |
| 2168 | unsigned char **newch, apr_size_t n) |
| 2169 | { |
| 2170 | struct uncompress_parms parm; |
| 2171 | apr_file_t *pipe_out = NULL; |
| 2172 | apr_pool_t *sub_context; |
| 2173 | apr_status_t rv; |
| 2174 | |
| 2175 | parm.r = r; |
| 2176 | parm.method = method; |
| 2177 | |
| 2178 | /* We make a sub_pool so that we can collect our child early, otherwise |
| 2179 | * there are cases (i.e. generating directory indices with mod_autoindex) |
| 2180 | * where we would end up with LOTS of zombies. |
| 2181 | */ |
| 2182 | if (apr_pool_create(&sub_context, r->pool) != APR_SUCCESS) |
| 2183 | return -1; |
| 2184 | apr_pool_tag(sub_context, "magic_uncompress"); |
| 2185 | |
| 2186 | if ((rv = create_uncompress_child(&parm, sub_context, &pipe_out)) != APR_SUCCESS) { |
| 2187 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01553) |
| 2188 | MODNAME ": couldn't spawn uncompress process: %s", r->uri); |
| 2189 | return -1; |
| 2190 | } |
| 2191 | |
| 2192 | *newch = (unsigned char *) apr_palloc(r->pool, n); |
| 2193 | rv = apr_file_read(pipe_out, *newch, &n); |
| 2194 | if (n == 0) { |
| 2195 | apr_pool_destroy(sub_context); |
| 2196 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01554) |
| 2197 | MODNAME ": read failed from uncompress of %s", r->filename); |
| 2198 | return -1; |
| 2199 | } |
| 2200 | apr_pool_destroy(sub_context); |
| 2201 | return n; |
| 2202 | } |
| 2203 | |
| 2204 | /* |
| 2205 | * is_tar() -- figure out whether file is a tar archive. |
no test coverage detected