From 361b4ed016a06717682e4071aa499a52b6c29dda Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 14 Dec 2010 15:00:15 +0100 Subject: s4:tls_tstream: fix partial reads, so that the gnutls layer doesn't read the same data twice metze --- source4/lib/tls/tls_tstream.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/tls/tls_tstream.c b/source4/lib/tls/tls_tstream.c index e1137571a5..09fe5714eb 100644 --- a/source4/lib/tls/tls_tstream.c +++ b/source4/lib/tls/tls_tstream.c @@ -305,12 +305,17 @@ static ssize_t tstream_tls_pull_function(gnutls_transport_ptr ptr, } if (tlss->pull.iov.iov_base) { + uint8_t *b; size_t n; + b = (uint8_t *)tlss->pull.iov.iov_base; + n = MIN(tlss->pull.iov.iov_len, size); - memcpy(buf, tlss->pull.iov.iov_base, n); + memcpy(buf, b, n); tlss->pull.iov.iov_len -= n; + b += n; + tlss->pull.iov.iov_base = (char *)b; if (tlss->pull.iov.iov_len == 0) { tlss->pull.iov.iov_base = NULL; } -- cgit