mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-11 16:29:42 +00:00
btrfs-progs: restore: check lzo compress length
When things go wrong for lzo-compressed btrfs, feeding lzo1x_decompress_safe() with corrupt data during restore can lead to crashes. Reduce the risk by adding a check on the input length. Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
f8c6dabca5
commit
93ebec96f2
@ -115,6 +115,12 @@ static int decompress_lzo(unsigned char *inbuf, char *outbuf, u64 compress_len,
|
||||
|
||||
while (tot_in < tot_len) {
|
||||
in_len = read_compress_length(inbuf);
|
||||
|
||||
if ((tot_in + LZO_LEN + in_len) > tot_len) {
|
||||
fprintf(stderr, "bad compress length %lu\n", in_len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
inbuf += LZO_LEN;
|
||||
tot_in += LZO_LEN;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user