]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Fixed slighty wrong i_stream_read_data() with _read_bytes()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 18:51:56 +0000 (21:51 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 18 May 2016 11:51:42 +0000 (14:51 +0300)
These calls were reading one byte more than they were intended to read.
This didn't really cause any problems, but now they're correct.

src/lda/main.c
src/lib-compression/istream-lz4.c
src/lib-lda/duplicate.c
src/lib-storage/index/dbox-multi/mdbox-purge.c
src/plugins/fts/fts-expunge-log.c

index 55f963f5b8947ad39b53054b6c05df6228604918..d61d78305119944561735484242f979ebc8245ac 100644 (file)
@@ -123,8 +123,8 @@ create_raw_stream(struct mail_deliver_context *ctx,
        input = i_stream_create_fd(fd, 4096, FALSE);
        input->blocking = TRUE;
        /* If input begins with a From-line, drop it */
-       ret = i_stream_read_data(input, &data, &size, 5);
-       if (ret > 0 && size >= 5 && memcmp(data, "From ", 5) == 0) {
+       ret = i_stream_read_bytes(input, &data, &size, 5);
+       if (ret > 0 && memcmp(data, "From ", 5) == 0) {
                /* skip until the first LF */
                i_stream_skip(input, 5);
                while (i_stream_read_more(input, &data, &size) > 0) {
index 77767112d5b68411720fc55219f0cf60355be84e..b5ce92dcb9725fb7a99b4b0990f901e78578528f 100644 (file)
@@ -100,8 +100,8 @@ static ssize_t i_stream_lz4_read(struct istream_private *stream)
        }
 
        if (zstream->chunk_left == 0) {
-               ret = i_stream_read_data(stream->parent, &data, &size,
-                                        IOSTREAM_LZ4_CHUNK_PREFIX_LEN);
+               ret = i_stream_read_bytes(stream->parent, &data, &size,
+                                         IOSTREAM_LZ4_CHUNK_PREFIX_LEN);
                if (ret < 0) {
                        stream->istream.stream_errno =
                                stream->parent->stream_errno;
index fdc81903c9cb5a9ad45607208d0a83c713ad7917..0e458d06ae044d385dd42e496f910c0d6c1de637 100644 (file)
@@ -93,7 +93,7 @@ duplicate_read_records(struct duplicate_file *file, struct istream *input,
        unsigned int change_count;
 
        change_count = 0;
-       while (i_stream_read_data(input, &data, &size, record_size) > 0) {
+       while (i_stream_read_bytes(input, &data, &size, record_size) > 0) {
                if (record_size == sizeof(hdr))
                        memcpy(&hdr, data, sizeof(hdr));
                else {
@@ -170,7 +170,7 @@ static int duplicate_read(struct duplicate_file *file)
 
        /* <timestamp> <id_size> <user_size> <id> <user> */
        input = i_stream_create_fd(fd, DUPLICATE_BUFSIZE, FALSE);
-       if (i_stream_read_data(input, &data, &size, sizeof(hdr)) > 0) {
+       if (i_stream_read_bytes(input, &data, &size, sizeof(hdr)) > 0) {
                memcpy(&hdr, data, sizeof(hdr));
                if (hdr.version == 0 || hdr.version > DUPLICATE_VERSION + 10) {
                        /* FIXME: backwards compatibility with v1.0 */
index 56d8d16cc85c08e9e1023220d81ef6f55b72d833..a8911412cce92bfa5f168cdd1524a8046c88f957 100644 (file)
@@ -69,8 +69,8 @@ mdbox_file_read_metadata_hdr(struct dbox_file *file,
        size_t size;
        int ret;
 
-       ret = i_stream_read_data(file->input, &data, &size,
-                                sizeof(*meta_hdr_r));
+       ret = i_stream_read_bytes(file->input, &data, &size,
+                                 sizeof(*meta_hdr_r));
        if (ret <= 0) {
                i_assert(ret == -1);
                if (file->input->stream_errno == 0) {
index 1b5861afac87274b17adf2219896380748f9d7cf..cf94ba12bb0925fdd4b6ab03eddfb6e8e6e02c78 100644 (file)
@@ -447,7 +447,7 @@ fts_expunge_log_read_next(struct fts_expunge_log_read_ctx *ctx)
                return NULL;
 
        /* initial read to try to get the record */
-       (void)i_stream_read_data(ctx->input, &data, &size, IO_BLOCK_SIZE);
+       (void)i_stream_read_bytes(ctx->input, &data, &size, IO_BLOCK_SIZE);
        if (size == 0 && ctx->input->stream_errno == 0) {
                /* expected EOF - mark the file as read by unlinking it */
                if (ctx->unlink)
@@ -455,8 +455,8 @@ fts_expunge_log_read_next(struct fts_expunge_log_read_ctx *ctx)
 
                /* try reading again, in case something new was written */
                i_stream_sync(ctx->input);
-               (void)i_stream_read_data(ctx->input, &data, &size,
-                                        IO_BLOCK_SIZE);
+               (void)i_stream_read_bytes(ctx->input, &data, &size,
+                                         IO_BLOCK_SIZE);
        }
        if (size < sizeof(*rec)) {
                if (size == 0 && ctx->input->stream_errno == 0) {