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

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


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

-------------- next part --------------
Index: lib/gnutls_buffers.c
===================================================================
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.\nRB: Requested %d bytes\n", session->internals.record_recv_buffer.length, ret2, sizeOfPtr);
-			session->internals.have_peeked_data = 1;
+			if (!session->internals._gnutls_pull_func) 
+				session->internals.have_peeked_data = 1;
 			session->internals.record_recv_buffer.length += ret2;
 
 		}



More information about the Gnutls-devel mailing list