summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-15 15:22:42 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-23 10:50:20 +0100
commitfefbab75208e570b26b45481db3e5ced6e9e0853 (patch)
tree1f57860d693218e82b045d4314e8415cace70c04
parent028476f19c0b6fd8cd5069837fcb3f0faf9d0173 (diff)
btrfs-progs: send-stream: check number of read bytes from stream
The read_buf does not verify that we've read the expected number of bytes. A corrupted of malformated stream will not be detdcted. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--send-stream.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/send-stream.c b/send-stream.c
index d2de9d39..80bf680b 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -61,13 +61,18 @@ static int read_buf(struct btrfs_send_stream *sctx, char *buf, size_t len)
}
if (rbytes == 0) {
ret = 1;
- goto out;
+ goto out_eof;
}
pos += rbytes;
}
-
ret = 0;
+out_eof:
+ if (pos < len) {
+ error("short read from stream: expected %zu read %zu", len, pos);
+ ret = -EIO;
+ }
+
out:
return ret;
}