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.
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) {
}
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;
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 {
/* <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 */
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) {
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)
/* 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) {