cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] sockfilt: read full blocks also in juggle()

From: Kamil Dudka <kdudka_at_redhat.com>
Date: Tue, 27 Dec 2011 19:59:37 +0100

nss-3.13 came with a security fix that broke curl's test-suite. It
splits a block of size N to a one-byte and N-1 bytes blocks, which
the testing server was not ready for, and it caused the FTPS tests to
be skipped. With this patch applied, the FTPS tests now work again.

An alternative workaround for this issue is to export the variable
NSS_SSL_CBC_RANDOM_IV=0 on client's side.

Bug: https://bugzilla.redhat.com/760060

---
 tests/server/sockfilt.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c
index 823b901..4bcb4ab 100644
--- a/tests/server/sockfilt.c
+++ b/tests/server/sockfilt.c
@@ -256,7 +256,8 @@ static void restore_signal_handlers(void)
  * retry of the read call.
  */
 
-static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
+static ssize_t fullread(int filedes, unsigned char *buffer, size_t nbytes,
+                        bool break_on_new_line)
 {
   int error;
   ssize_t rc;
@@ -285,7 +286,8 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
 
     nread += rc;
 
-  } while((size_t)nread < nbytes);
+  } while((size_t)nread < nbytes
+      && (!break_on_new_line || '\n' != buffer[nread - 1]));
 
   if(verbose)
     logmsg("read %zd bytes", nread);
@@ -346,7 +348,8 @@ static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
 
 static bool read_stdin(void *buffer, size_t nbytes)
 {
-  ssize_t nread = fullread(fileno(stdin), buffer, nbytes);
+  ssize_t nread = fullread(fileno(stdin), (unsigned char *) buffer, nbytes,
+                           /* break_on_new_line */ FALSE);
   if(nread != (ssize_t)nbytes) {
     logmsg("exiting...");
     return FALSE;
@@ -658,7 +661,8 @@ static bool juggle(curl_socket_t *sockfdp,
     }
 
     /* read from socket, pass on data to stdout */
-    nread_socket = sread(sockfd, buffer, sizeof(buffer));
+    nread_socket = fullread(sockfd, buffer, sizeof(buffer),
+                            /* break_on_new_line */ TRUE);
 
     if(nread_socket <= 0) {
       logmsg("====> Client disconnect");
-- 
1.7.1
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-27