File 23000-bnc716299-Fix-large-https-requests-Check-SSL-buffer-before-sel.patch of Package sblim-sfcb-sle11-sp1

From 3190102b9250700b0561245b84f0b205238aed90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
Date: Wed, 14 Sep 2011 14:41:53 +0200
Subject: [PATCH] Fix large https requests: Check SSL buffer before select()
 on file descriptor

There is a 5000 char buffer for http/https socket reads and larger
requests (http content length) need another read() to get the
remaining data.
Doing this via select() and read() on the socket is fine for http but
fails for https since SSL has its own decrypt/buffer mode.
This made large https requests fail as the select() on the socket
timed out since the data was already in the SSL buffer.

Fix: Use SSL_pending() to check if there is data left in the SSL
buffer before doing a select() on the socket.
---
 httpAdapter.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/httpAdapter.c b/httpAdapter.c
index 4496ddf..56236e2 100644
--- a/httpAdapter.c
+++ b/httpAdapter.c
@@ -388,7 +388,12 @@ static int readData(CommHndl conn_fd, char *into, int length)
    FD_SET(conn_fd.socket,&httpfds);
 
    while (c < length) {
-      isReady = select(conn_fd.socket+1,&httpfds,NULL,NULL,&httpSelectTimeout);
+      if (conn_fd.ssl && SSL_pending(conn_fd.ssl)) {
+	isReady = 1;
+      }
+      else {
+	isReady = select(conn_fd.socket+1,&httpfds,NULL,NULL,&httpSelectTimeout);
+      }
       if (isReady == 0) {
          c = -1;
          break;
-- 
1.7.6.1

openSUSE Build Service is sponsored by