[gnutls-dev] [PATCH] bug in lib/gnutls_buffers.c

Sergey Poznyakoff gray@Mirddin.farlep.net
Wed May 28 11:50:02 2003


--1804289383-1054057293=:9289
Content-ID: <20030527204133.9289.1@Mirddin.farlep.net>
Content-Type: text/plain

Hello,

The buffering mechanism in gnutls_buffers.c does not work when
the user-defined pull function is used. Here's the short
synopsis:

The comment to _gnutls_io_clear_peeked_data() states that `this
function is only used with berkeley style sockets.', however no
provision is made to ensure this is so. This causes the function
to be called even if the pull function is used. Now, what happens
is that calling _gnutls_io_clear_peeked_data() after
_gnutls_read(..., MSG_PEEK) blocks the program, since it actually
attempts to read the same data twice.

Attached is the patch that corrects the bug.

Regards,
Sergey


--1804289383-1054057293=:9289
Content-transfer-encoding: quoted-printable
Content-Description: patchfile
Content-ID: <20030527204133.9289.1@Mirddin.farlep.net>
Content-Type: text/plain; name="gnutls.patch"

Index: lib/gnutls_buffers.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/gnutls/gnutls/lib/gnutls_buffers.c,v
retrieving revision 2.104
diff -p -u -r2.104 gnutls_buffers.c
--- lib/gnutls_buffers.c	24 Mar 2003 17:21:54 -0000	2.104
+++ lib/gnutls_buffers.c	27 May 2003 17:22:46 -0000
@@ -429,7 +429,8 @@ ssize_t _gnutls_io_read_buffered( gnutls
 		if (ret2 > 0) {
 			_gnutls_read_log("RB-PEEK: Read %d bytes in PEEK MODE.\n", ret2); =

 			_gnutls_read_log("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\n=
RB: Requested %d bytes\n", session->internals.record_recv_buffer.length, ret=
2, sizeOfPtr);
-			session->internals.have_peeked_data =3D 1;
+			if (!session->internals._gnutls_pull_func) =

+				session->internals.have_peeked_data =3D 1;
 			session->internals.record_recv_buffer.length +=3D ret2;
 =

 		}


--1804289383-1054057293=:9289--