transport: handle all return values of tsg_read
authorBernhard Miklautz <bernhard.miklautz@thincast.com>
Tue, 25 Nov 2014 21:55:39 +0000 (22:55 +0100)
committerBernhard Miklautz <bernhard.miklautz@thincast.com>
Wed, 26 Nov 2014 18:46:32 +0000 (19:46 +0100)
tsg_read can also return 0 which means that no data (complete PDU) is
currently available. This case wasn't handled properly.

Fixes #2056

libfreerdp/core/gateway/tsg.c
libfreerdp/core/transport.c

index 43b45a7..4475aea 100644 (file)
@@ -1401,6 +1401,16 @@ BOOL tsg_disconnect(rdpTsg* tsg)
        return TRUE;
 }
 
+/**
+ * @brief
+ *
+ * @param[in] tsg
+ * @param[in] data
+ * @param[in] length
+ * @return < 0 on error; 0 if not enough data is available (non blocking mode); > 0 bytes to read
+ */
+
+
 int tsg_read(rdpTsg* tsg, BYTE* data, UINT32 length)
 {
        int CopyLength;
index 01f648a..5154c19 100644 (file)
@@ -149,12 +149,16 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size)
        {
                BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
        }
+       else if (status == 0)
+       {
+               BIO_set_flags(bio, BIO_FLAGS_SHOULD_RETRY);
+       }
        else
        {
                BIO_set_flags(bio, BIO_FLAGS_READ);
        }
 
-       return status >= 0 ? status : -1;
+       return status > 0 ? status : -1;
 }
 
 static int transport_bio_tsg_puts(BIO* bio, const char* str)