mirror of git://git.gnupg.org/gnupg.git
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:
parent
00b7767bc6
commit
abe3a9043f
|
@ -117,6 +117,7 @@ struct outstream_cookie_s
|
||||||
char buffer[4000]; /* Data ring buffer. */
|
char buffer[4000]; /* Data ring buffer. */
|
||||||
size_t buffer_len; /* The amount of data in the 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_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)
|
#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_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_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_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
|
static int
|
||||||
buffer_get_data (struct outstream_cookie_s *cookie, char *dst, int cnt)
|
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)
|
if (chunk > left)
|
||||||
chunk = left;
|
chunk = left;
|
||||||
|
|
||||||
memcpy (dst, BUFFER_CUR_POS (cookie), chunk);
|
memcpy (dst, BUFFER_CUR_READ_POS (cookie), chunk);
|
||||||
BUFFER_INC_POS (cookie, chunk);
|
BUFFER_INC_READ_POS (cookie, chunk);
|
||||||
left -= chunk;
|
left -= chunk;
|
||||||
dst += chunk;
|
dst += chunk;
|
||||||
|
|
||||||
if (left)
|
if (left)
|
||||||
{
|
{
|
||||||
memcpy (dst, BUFFER_CUR_POS (cookie), left);
|
memcpy (dst, BUFFER_CUR_READ_POS (cookie), left);
|
||||||
BUFFER_INC_POS (cookie, left);
|
BUFFER_INC_READ_POS (cookie, left);
|
||||||
}
|
}
|
||||||
|
|
||||||
return amount;
|
return amount;
|
||||||
|
|
Loading…
Reference in New Issue