Skip to content

Commit 489f5ef

Browse files
committed
* modules/generators/mod_cgid.c (get_req): Fix wrong sizeof in
allocation of core_request_config, which used sizeof(core_module). (cgid_server): Fix stale rv passed to ap_log_error for passed fd debug message. (include_cmd): Fix double registration of cleanup_script which could kill a garbage pid when get_cgi_pid failed. Check return value of send_req. Change return type to apr_status_t to match declaration in cgi_common.h Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> GitHub: PR#669 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1935192 13f79535-47bb-0310-9956-ffa450edef68
1 parent d7ac43a commit 489f5ef

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

modules/generators/mod_cgid.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static apr_status_t get_req(int fd, request_rec *r, char **argv0, char ***env,
538538
/* handle module indexes and such */
539539
rconf = (void **)ap_create_request_config(r->pool);
540540

541-
temp_core = (core_request_config *)apr_palloc(r->pool, sizeof(core_module));
541+
temp_core = (core_request_config *)apr_palloc(r->pool, sizeof *temp_core);
542542
rconf[AP_CORE_MODULE_INDEX] = (void *)temp_core;
543543
r->request_config = (ap_conf_vector_t *)rconf;
544544
ap_set_module_config(r->request_config, &cgid_module, (void *)&req->ugid);
@@ -873,7 +873,7 @@ static int cgid_server(void *data)
873873
errfileno = STDERR_FILENO;
874874
}
875875
else {
876-
ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, main_server,
876+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, main_server,
877877
"using passed fd %d as stderr", errfileno);
878878
/* Limit the received fd lifetime to pool lifetime */
879879
apr_pool_cleanup_register(ptrans, (void *)((long)errfileno),
@@ -1739,8 +1739,8 @@ static void add_ssi_vars(request_rec *r)
17391739
}
17401740
}
17411741

1742-
static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
1743-
apr_bucket_brigade *bb, const char *command)
1742+
static apr_status_t include_cmd(include_ctx_t *ctx, ap_filter_t *f,
1743+
apr_bucket_brigade *bb, const char *command)
17441744
{
17451745
char **env;
17461746
int sd;
@@ -1758,30 +1758,29 @@ static int include_cmd(include_ctx_t *ctx, ap_filter_t *f,
17581758
env = ap_create_environment(r->pool, r->subprocess_env);
17591759

17601760
if ((retval = connect_to_daemon(&sd, r, conf)) != OK) {
1761-
return retval;
1761+
return APR_EGENERAL;
17621762
}
17631763

1764-
send_req(sd, NULL, r, command, env, SSI_REQ);
1764+
rv = send_req(sd, NULL, r, command, env, SSI_REQ);
1765+
if (rv) {
1766+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
1767+
"could not send request to cgi daemon (for SSI)");
1768+
return rv;
1769+
}
17651770

17661771
info = apr_palloc(r->pool, sizeof(struct cleanup_script_info));
17671772
info->conf = conf;
17681773
info->r = r;
17691774
rv = get_cgi_pid(r, conf, &(info->pid));
1770-
if (APR_SUCCESS == rv) {
1771-
/* for this type of request, the script is invoked through an
1772-
* intermediate shell process... cleanup_script is only able
1773-
* to knock out the shell process, not the actual script
1774-
*/
1775-
apr_pool_cleanup_register(r->pool, info,
1776-
cleanup_script,
1777-
apr_pool_cleanup_null);
1778-
}
1779-
else {
1780-
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "error determining cgi PID (for SSI)");
1775+
if (rv) {
1776+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, "error determining cgi daemon PID (for SSI)");
1777+
return rv;
17811778
}
17821779

1783-
apr_pool_cleanup_register(r->pool, info,
1784-
cleanup_script,
1780+
/* For this type of request, the script is invoked through an
1781+
* intermediate shell process... cleanup_script is only able to
1782+
* knock out the shell process, not the actual script. */
1783+
apr_pool_cleanup_register(r->pool, info, cleanup_script,
17851784
apr_pool_cleanup_null);
17861785

17871786
/* We are putting the socket discriptor into an apr_file_t so that we can

0 commit comments

Comments
 (0)