dirmngr,w32: Fix ldap crl read on windows

Summary:
* dirmngr/ldap-wrapper-ce.c (outstream_cookie_s): Add buffer_read_pos.
(buffer_get_data): Use seperate read pos.

--
Using a single buffer pos for reading and writing caused the read
to return 0 as it read from the end of the buffer. Now we use
a seperate reader position.

Differential: D427

Signed-off-by: Andre Heinecke <aheinecke@intevation.de>
This commit is contained in:
Andre Heinecke 2017-04-26 09:39:06 +02:00
parent 00b7767bc6
commit abe3a9043f
No known key found for this signature in database
GPG Key ID: 1FDF723CF462B6B1
1 changed files with 7 additions and 4 deletions

View File

@ -117,6 +117,7 @@ struct outstream_cookie_s
char buffer[4000]; /* Data ring buffer. */
size_t buffer_len; /* The amount of data in the BUFFER. */
size_t buffer_pos; /* The next read position of the BUFFER. */
size_t buffer_read_pos; /* The next read position of the BUFFER. */
};
#define BUFFER_EMPTY(c) ((c)->buffer_len == 0)
@ -125,6 +126,8 @@ struct outstream_cookie_s
#define BUFFER_SPACE_AVAILABLE(c) (DIM((c)->buffer) - (c)->buffer_len)
#define BUFFER_INC_POS(c,n) (c)->buffer_pos = ((c)->buffer_pos + (n)) % DIM((c)->buffer)
#define BUFFER_CUR_POS(c) (&(c)->buffer[(c)->buffer_pos])
#define BUFFER_INC_READ_POS(c,n) (c)->buffer_read_pos = ((c)->buffer_read_pos + (n)) % DIM((c)->buffer)
#define BUFFER_CUR_READ_POS(c) (&(c)->buffer[(c)->buffer_read_pos])
static int
buffer_get_data (struct outstream_cookie_s *cookie, char *dst, int cnt)
@ -143,15 +146,15 @@ buffer_get_data (struct outstream_cookie_s *cookie, char *dst, int cnt)
if (chunk > left)
chunk = left;
memcpy (dst, BUFFER_CUR_POS (cookie), chunk);
BUFFER_INC_POS (cookie, chunk);
memcpy (dst, BUFFER_CUR_READ_POS (cookie), chunk);
BUFFER_INC_READ_POS (cookie, chunk);
left -= chunk;
dst += chunk;
if (left)
{
memcpy (dst, BUFFER_CUR_POS (cookie), left);
BUFFER_INC_POS (cookie, left);
memcpy (dst, BUFFER_CUR_READ_POS (cookie), left);
BUFFER_INC_READ_POS (cookie, left);
}
return amount;