diff options
author | Joe Orton <jorton@apache.org> | 2019-10-02 11:58:01 +0200 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2019-10-02 11:58:01 +0200 |
commit | 2715cad0f948b0c7b53f1b8f24526d9971842e90 (patch) | |
tree | 035eb8033f9b4087e804c20a4c331c0c1f83ae5d /modules/generators | |
parent | Merge r1866760 from ^/httpd/apreq/trunk: (diff) | |
download | apache2-2715cad0f948b0c7b53f1b8f24526d9971842e90.tar.xz apache2-2715cad0f948b0c7b53f1b8f24526d9971842e90.zip |
* modules/generators/mod_cgid.c (sock_readhdr): Only set up control
message block when required; add some additional error handling.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1867878 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/generators')
-rw-r--r-- | modules/generators/mod_cgid.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 67f458a27e..4354499b4f 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -381,11 +381,12 @@ static apr_status_t sock_readhdr(int fd, int *errfd, void *vbuf, size_t buf_size msg.msg_iov = &vec; msg.msg_iovlen = 1; - - msg.msg_control = u.buf; - msg.msg_controllen = sizeof(u.buf); - if (errfd) *errfd = 0; + if (errfd) { + msg.msg_control = u.buf; + msg.msg_controllen = sizeof(u.buf); + *errfd = 0; + } /* use MSG_WAITALL to skip loop on truncated reads */ do { @@ -395,10 +396,17 @@ static apr_status_t sock_readhdr(int fd, int *errfd, void *vbuf, size_t buf_size if (rc == 0) { return ECONNRESET; } - - cmsg = CMSG_FIRSTHDR(&msg); + else if (rc < 0) { + return errno; + } + else if (rc != buf_size) { + /* MSG_WAITALL should ensure the recvmsg blocks until the + * entire length is read, but let's be paranoid. */ + return APR_INCOMPLETE; + } + if (errfd - && cmsg + && (cmsg = CMSG_FIRSTHDR(&msg)) != NULL && cmsg->cmsg_len == CMSG_LEN(sizeof(*errfd)) && cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { |