Module: wine Branch: master Commit: 7bb7d08d1930dd56569dedf979660b6e26aeec64 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7bb7d08d1930dd56569dedf979...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Oct 5 16:51:19 2011 +0200
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().
---
dlls/secur32/schannel.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/secur32/schannel.c b/dlls/secur32/schannel.c index 0355982..253e71a 100644 --- a/dlls/secur32/schannel.c +++ b/dlls/secur32/schannel.c @@ -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;