forked from Mirrors/btrfs-progs
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>master
parent
028476f19c
commit
fefbab7520
|
@ -61,13 +61,18 @@ static int read_buf(struct btrfs_send_stream *sctx, char *buf, size_t len)
|
||||||
}
|
}
|
||||||
if (rbytes == 0) {
|
if (rbytes == 0) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto out;
|
goto out_eof;
|
||||||
}
|
}
|
||||||
pos += rbytes;
|
pos += rbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
out_eof:
|
||||||
|
if (pos < len) {
|
||||||
|
error("short read from stream: expected %zu read %zu", len, pos);
|
||||||
|
ret = -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue