>From 0b328cd949b2aa67e45efda62a42060cfe7f6ad7 Mon Sep 17 00:00:00 2001
From: Markus Klinik <markus.klinik () gmx de>
Date: Fri, 26 Feb 2010 20:03:57 +0100
Subject: [PATCH 1/8] ncat_recv: don't write to pending if it is NULL


diff --git a/ncat_core.c b/ncat_core.c
index 709832a..fed3d56 100644
--- a/ncat_core.c
+++ b/ncat_core.c
@@ -211,12 +211,17 @@ int resolve(char *hostname, unsigned short port,
    function that this function may call, which takes data out of the socket
    buffer (so select may not indicate the socket is readable) and keeps it in
    its own buffer. *pending holds the result of calling SSL_pending. See
-   http://www.mail-archive.com/openssl-dev () openssl org/msg24324.html. */
+   http://www.mail-archive.com/openssl-dev () openssl org/msg24324.html.
+
+   If pending is NULL, it is ignored.
+   
+   */
 int ncat_recv(struct fdinfo *fdn, char *buf, size_t size, int *pending)
 {
     int n;
 
-    *pending = 0;
+    if( NULL != pending )
+        *pending = 0;
 
 #ifdef HAVE_OPENSSL
     if (o.ssl && fdn->ssl)
@@ -238,7 +243,7 @@ int ncat_recv(struct fdinfo *fdn, char *buf, size_t size, int *pending)
     /* SSL can buffer our input, so doing another select() won't necessarily
        work for us. Indicate to the caller that this function must be called
        again to get more data. */
-    if (o.ssl && fdn->ssl)
+    if (o.ssl && fdn->ssl && NULL != pending)
         *pending = SSL_pending(fdn->ssl);
 #endif
 
-- 
1.6.6.1

