Fixed NULL dereference on GLISTENPORT codepath.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 31 May 2009 15:02:22 -0500
changeset 134 dc073c76a283
parent 133 3004c3bd801c
child 135 36e73dbcadf3
Fixed NULL dereference on GLISTENPORT codepath.
nph-offload.c
--- a/nph-offload.c	Sun May 31 14:52:06 2009 -0500
+++ b/nph-offload.c	Sun May 31 15:02:22 2009 -0500
@@ -1716,16 +1716,21 @@
             char onebyte = 0;
             const ssize_t recvval = recv(GSocket, &onebyte, sizeof (onebyte), MSG_DONTWAIT);
             deadsocket = (recvval == 0);
+            if (deadsocket)
+                debugEcho("EOF on socket!");
             if ( ((recvval < 0) && (errno == EAGAIN)) || (deadsocket) )
                 break;
         } // while
+        #else
+        if ( (feof(stdout)) || (ferror(stdout)) )
+        {
+            debugEcho("EOF or error on stdout!");
+            deadsocket = 1;
+        } // if
         #endif
 
-        if (deadsocket || feof(stdout) || ferror(stdout))
-        {
-            debugEcho("EOF on stdout!");
+        if (deadsocket)
             break;
-        } // if
 
         if ((br >= startRange) && (br < endRange))
         {