]> sjero.net Git - wget/commitdiff
gnutls: Read correctly last chunk of data.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 23 Oct 2010 23:21:01 +0000 (01:21 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 23 Oct 2010 23:21:01 +0000 (01:21 +0200)
src/ChangeLog
src/gnutls.c

index a3b7921ffa06dca10cc4f3e6295ad554253c77d6..4c17f4a440a742f2afbecf37afcf884098168523 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-24  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * gnutls.c (wgnutls_peek): Do not return an error when
+       `gnutls_record_recv' fails but some data is already available.
+
 2010-10-23  Giuseppe Scrivano  <gscrivano@gnu.org>
 
        * Makefile.am (LIBS): Remove @LIBGNUTLS@ and use @W32LIBS@ as last
index 440b1aed2de7c429d6b0f36cda97804378d4efa3..1bf4aefdbfdb17251eb8955f74a28065d99aef90 100644 (file)
@@ -104,7 +104,8 @@ ssl_init ()
   return true;
 }
 
-struct wgnutls_transport_context {
+struct wgnutls_transport_context
+{
   gnutls_session session;       /* GnuTLS session handle */
   int last_error;               /* last error returned by read/write/... */
 
@@ -144,6 +145,7 @@ wgnutls_read (int fd, char *buf, int bufsize, void *arg)
 
   if (ret < 0)
     ctx->last_error = ret;
+
   return ret;
 }
 
@@ -190,7 +192,12 @@ wgnutls_peek (int fd, char *buf, int bufsize, void *arg)
       while (ret == GNUTLS_E_INTERRUPTED);
 
       if (ret < 0)
-        return ret;
+        {
+          if (offset)
+            ret = 0;
+          else
+            return ret;
+        }
 
       if (ret > 0)
         {
@@ -223,7 +230,8 @@ wgnutls_close (int fd, void *arg)
 /* gnutls_transport is the singleton that describes the SSL transport
    methods provided by this file.  */
 
-static struct transport_implementation wgnutls_transport = {
+static struct transport_implementation wgnutls_transport =
+{
   wgnutls_read, wgnutls_write, wgnutls_poll,
   wgnutls_peek, wgnutls_errstr, wgnutls_close
 };