You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2019/10/02 09:58:02 UTC

svn commit: r1867878 - /httpd/httpd/trunk/modules/generators/mod_cgid.c

Author: jorton
Date: Wed Oct  2 09:58:01 2019
New Revision: 1867878

URL: http://svn.apache.org/viewvc?rev=1867878&view=rev
Log:
* modules/generators/mod_cgid.c (sock_readhdr): Only set up control
  message block when required; add some additional error handling.

Modified:
    httpd/httpd/trunk/modules/generators/mod_cgid.c

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=1867878&r1=1867877&r2=1867878&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Wed Oct  2 09:58:01 2019
@@ -381,11 +381,12 @@ static apr_status_t sock_readhdr(int fd,
     
     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,
     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) {