~ubuntu-branches/ubuntu/saucy/curl/saucy

« back to all changes in this revision

Viewing changes to debian/patches/09_openssl-recv.patch

  • Committer: Package Import Robot
  • Author(s): Oussama Bounaim
  • Date: 2013-07-23 18:42:00 UTC
  • mfrom: (70.2.1 curl)
  • Revision ID: package-import@ubuntu.com-20130723184200-w0qx6nwya6ay03ul
Tags: 7.31.0-2ubuntu1
* Merge from Debian, Remaining changes: 
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 8a7a277c086199b37c07a8e01165168037866f3e Mon Sep 17 00:00:00 2001
 
2
From: Daniel Stenberg <daniel@haxx.se>
 
3
Date: Sun, 23 Jun 2013 10:31:04 +0200
 
4
Subject: [PATCH] ossl_recv: check for an OpenSSL error, don't assume
 
5
 
 
6
When we recently started to treat a zero return code from SSL_read() as
 
7
an error we also got false positives - which primarily looks to be
 
8
because the OpenSSL documentation is wrong and a zero return code is not
 
9
at all an error case in many situations.
 
10
 
 
11
Now ossl_recv() will check with ERR_get_error() to see if there is a
 
12
stored error and only then consider it to be a true error if SSL_read()
 
13
returned zero.
 
14
 
 
15
Bug: http://curl.haxx.se/bug/view.cgi?id=1249
 
16
Bug-Debian: http://bugs.debian.org/714050
 
17
Reported-by: Nach M. S.
 
18
Patch-by: Nach M. S.
 
19
---
 
20
 lib/ssluse.c | 18 ++++++++++++------
 
21
 1 file changed, 12 insertions(+), 6 deletions(-)
 
22
 
 
23
diff --git a/lib/ssluse.c b/lib/ssluse.c
 
24
index 1bb7327..b9560e5 100644
 
25
--- a/lib/ssluse.c
 
26
+++ b/lib/ssluse.c
 
27
@@ -2608,13 +2608,19 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
 
28
       *curlcode = CURLE_AGAIN;
 
29
       return -1;
 
30
     default:
 
31
-      /* openssl/ssl.h says "look at error stack/return value/errno" */
 
32
+      /* openssl/ssl.h for SSL_ERROR_SYSCALL says "look at error stack/return
 
33
+         value/errno" */
 
34
+      /* http://www.openssl.org/docs/crypto/ERR_get_error.html */
 
35
       sslerror = ERR_get_error();
 
36
-      failf(conn->data, "SSL read: %s, errno %d",
 
37
-            ERR_error_string(sslerror, error_buffer),
 
38
-            SOCKERRNO);
 
39
-      *curlcode = CURLE_RECV_ERROR;
 
40
-      return -1;
 
41
+      if((nread < 0) || sslerror) {
 
42
+        /* If the return code was negative or there actually is an error in the
 
43
+           queue */
 
44
+        failf(conn->data, "SSL read: %s, errno %d",
 
45
+              ERR_error_string(sslerror, error_buffer),
 
46
+              SOCKERRNO);
 
47
+        *curlcode = CURLE_RECV_ERROR;
 
48
+        return -1;
 
49
+      }
 
50
     }
 
51
   }
 
52
   return nread;
 
53
-- 
 
54
1.8.1.6
 
55