From: Nick Kew Date: Sat, 27 Dec 2008 02:13:47 +0000 (+0000) Subject: PR#39332: fix for segfault problem with mod_cgid on Solaris X-Git-Tag: 2.3.1~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4a75ed08f7c80bfc487661de72d29edbcef26df;p=apache PR#39332: fix for segfault problem with mod_cgid on Solaris Patch by Masaoki Kobayashi git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@729579 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index fde51eb253..683bbbb481 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.1 [ When backported to 2.2.x, remove entry from this file ] + *) mod_cgid: fix segfault problem on solaris. + PR 39332 [Masaoki Kobayashi ] + *) mod_proxy_scgi: Added. [André Malo] *) mod_cache: Introduce 'no-cache' per-request environment variable @@ -17,7 +20,7 @@ Changes with Apache 2.3.1 PR 46380 [Ruediger Pluem] *) scoreboard: Remove unused sb_type from process_score. - [Torsten Foertsch , Chris Darroch] + [Torsten Foertsch , Chris Darroch] *) mod_ssl: Add SSLRenegBufferSize directive to allow changing the size of the buffer used for the request-body where necessary diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 7270652bac..0496e38028 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -342,6 +342,33 @@ static apr_status_t sock_write(int fd, const void *buf, size_t buf_size) return APR_SUCCESS; } +static apr_status_t sock_writev(int fd, request_rec *r, int count, ...) +{ + va_list ap; + int rc; + struct iovec *vec; + int i; + int total_bytes = 0; + + vec = (struct iovec *)apr_palloc(r->pool, count * sizeof(struct iovec)); + va_start(ap, count); + for(i=0; iserver->loglevel; /* Write the request header */ - if ((stat = sock_write(fd, &req, sizeof(req))) != APR_SUCCESS) { - return stat; + if (req.args_len) { + stat = sock_writev(fd, r, 5, + &req, sizeof(req), + r->filename, req.filename_len, + argv0, req.argv0_len, + r->uri, req.uri_len, + r->args, req.args_len); + } else { + stat = sock_writev(fd, r, 4, + &req, sizeof(req), + r->filename, req.filename_len, + argv0, req.argv0_len, + r->uri, req.uri_len); } - /* Write filename, argv0, uri, and args */ - if ((stat = sock_write(fd, r->filename, req.filename_len)) != APR_SUCCESS || - (stat = sock_write(fd, argv0, req.argv0_len)) != APR_SUCCESS || - (stat = sock_write(fd, r->uri, req.uri_len)) != APR_SUCCESS) { + if (stat != APR_SUCCESS) { return stat; } - if (req.args_len) { - if ((stat = sock_write(fd, r->args, req.args_len)) != APR_SUCCESS) { - return stat; - } - } /* write the environment variables */ for (i = 0; i < req.env_count; i++) { apr_size_t curlen = strlen(env[i]); - if ((stat = sock_write(fd, &curlen, sizeof(curlen))) != APR_SUCCESS) { - return stat; - } - - if ((stat = sock_write(fd, env[i], curlen)) != APR_SUCCESS) { + if ((stat = sock_writev(fd, r, 2, &curlen, sizeof(curlen), + env[i], curlen)) != APR_SUCCESS) { return stat; } }