diff options
author | Dan Winship <danw@src.gnome.org> | 2000-11-28 11:26:51 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-11-28 11:26:51 +0800 |
commit | 89ae418e500b8503bd8edddb60c5a429539404ee (patch) | |
tree | 27fe3048b93d9850670c85acb94aeeabb4e91cc9 /camel/camel-stream-buffer.c | |
parent | 26fccb498293b89b9bef804fc85436e00a4ee1cd (diff) | |
download | gsoc2013-evolution-89ae418e500b8503bd8edddb60c5a429539404ee.tar.gz gsoc2013-evolution-89ae418e500b8503bd8edddb60c5a429539404ee.tar.zst gsoc2013-evolution-89ae418e500b8503bd8edddb60c5a429539404ee.zip |
Make this gratuitously more complicated. No wait, I mean, fix bugs. Now
* providers/imap/camel-imap-command.c (imap_read_untagged): Make
this gratuitously more complicated. No wait, I mean, fix bugs. Now
fully handles NULs in the data stream (which "can't happen" but
do) and also handles responses containing multiple literals. Also
does less copying than the original code.
* camel-stream-buffer.c (stream_read): Fix a bug that could make
it lose sync and/or overrun buffers.
svn path=/trunk/; revision=6688
Diffstat (limited to 'camel/camel-stream-buffer.c')
-rw-r--r-- | camel/camel-stream-buffer.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c index 26d7d3197a..8641206006 100644 --- a/camel/camel-stream-buffer.c +++ b/camel/camel-stream-buffer.c @@ -247,12 +247,13 @@ stream_read (CamelStream *stream, char *buffer, size_t n) } else { bytes_read = camel_stream_read(sbf->stream, sbf->buf, sbf->size); if (bytes_read>0) { + size_t bytes_used = bytes_read > n ? n : bytes_read; sbf->ptr = sbf->buf; sbf->end = sbf->buf+bytes_read; - memcpy(bptr, sbf->ptr, n); - sbf->ptr += n; - bptr += n; - n -= bytes_read; + memcpy(bptr, sbf->ptr, bytes_used); + sbf->ptr += bytes_used; + bptr += bytes_used; + n -= bytes_used; } } } else { |