Leave SIGPIPE handling alone. Caller must disable or handle that.
authorJennifer Richards <jennifer@painless-security.com>
Tue, 2 Aug 2016 15:24:28 +0000 (11:24 -0400)
committerJennifer Richards <jennifer@painless-security.com>
Tue, 2 Aug 2016 15:24:28 +0000 (11:24 -0400)
gsscon/gsscon_common.c

index c391698..b8d4fcf 100755 (executable)
@@ -52,8 +52,6 @@
  * or implied warranty.
  */
 
-#include <signal.h>
-
 #include <gsscon.h>
 
 /* --------------------------------------------------------------------------- */
@@ -135,11 +133,7 @@ static int WriteBuffer (int         inSocket,
         do {
             ssize_t count;
 
-            /* disable the SIGPIPE signal while we write so that we can handle a
-             * broken pipe error gracefully */
-            signal(SIGPIPE, SIG_IGN); /* temporarily disable */
             count = write (inSocket, ptr, inBufferLength - bytesWritten);
-            signal(SIGPIPE, SIG_DFL); /* reenable */
 
             if (count < 0) {
                 /* Try again on EINTR */
@@ -177,15 +171,16 @@ int gsscon_read_token (int      inSocket,
     if (!err) {
        tokenLength = ntohl (tokenLength);
        token = malloc (tokenLength);
-       memset (token, 0, tokenLength); 
+        if (token==NULL) {
+          err=EIO;
+        } else {
+          memset (token, 0, tokenLength); 
         
-       err = ReadBuffer (inSocket, tokenLength, token);
+          err = ReadBuffer (inSocket, tokenLength, token);
+        }
     }
     
     if (!err) {
-    //    printf ("Read token:\n");
-    //    PrintBuffer (token, tokenLength);
-        
        *outTokenLength = tokenLength;
         *outTokenValue = token;        
         token = NULL; /* only free on error */