From 42186a9bcc2b69b8f272fc969216e7ba7361cac6 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Tue, 2 Aug 2016 11:24:28 -0400 Subject: [PATCH] Leave SIGPIPE handling alone. Caller must disable or handle that. --- gsscon/gsscon_common.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/gsscon/gsscon_common.c b/gsscon/gsscon_common.c index c391698..b8d4fcf 100755 --- a/gsscon/gsscon_common.c +++ b/gsscon/gsscon_common.c @@ -52,8 +52,6 @@ * or implied warranty. */ -#include - #include /* --------------------------------------------------------------------------- */ @@ -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 */ -- 2.1.4