Commit 7bb7d08d authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

secur32: Handle the schan_buffers limit field in schan_get_buffer() instead of schan_pull().

Aside from being the right place, we depend on schan_get_buffer() not returning a buffer if there's no space left in schan_imp_recv() / schan_imp_send().
parent d25f614c
......@@ -433,7 +433,7 @@ static void init_schan_buffers(struct schan_buffers *s, const PSecBufferDesc des
int (*get_next_buffer)(const struct schan_transport *, struct schan_buffers *))
{
s->offset = 0;
s->limit = 0;
s->limit = ~0UL;
s->desc = desc;
s->current_buffer_idx = -1;
s->allow_buffer_resize = FALSE;
......@@ -507,6 +507,8 @@ char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s,
schan_resize_current_buffer(s, s->offset + *count);
max_count = buffer->cbBuffer - s->offset;
if (s->limit != ~0UL && s->limit < max_count)
max_count = s->limit;
if (!max_count)
{
int buffer_idx;
......@@ -523,7 +525,11 @@ char *schan_get_buffer(const struct schan_transport *t, struct schan_buffers *s,
return schan_get_buffer(t, s, count);
}
if (*count > max_count) *count = max_count;
if (*count > max_count)
*count = max_count;
if (s->limit != ~0UL)
s->limit -= *count;
return (char *)buffer->pvBuffer + s->offset;
}
......@@ -559,13 +565,6 @@ int schan_pull(struct schan_transport *t, void *buff, size_t *buff_len)
if (!b)
return EAGAIN;
if (t->in.limit != 0 && t->in.offset + local_len >= t->in.limit)
{
local_len = t->in.limit - t->in.offset;
if (local_len == 0)
return EAGAIN;
}
memcpy(buff, b, local_len);
t->in.offset += local_len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment