mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-22 14:13:04 +00:00
btrfs-progs: scrub: improved error handling in scrub_read_file
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0ce97733fe
commit
5b16054958
@ -481,7 +481,10 @@ static struct scrub_file_record **scrub_read_file(int fd, int report_errors)
|
||||
|
||||
again:
|
||||
old_avail = avail - i;
|
||||
BUG_ON(old_avail < 0);
|
||||
if (old_avail < 0) {
|
||||
error("scrub record file corrupted near byte %d", i);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
if (old_avail)
|
||||
memmove(l, l + i, old_avail);
|
||||
avail = read(fd, l + old_avail, sizeof(l) - old_avail);
|
||||
@ -650,7 +653,9 @@ skip:
|
||||
} while (i < avail);
|
||||
continue;
|
||||
}
|
||||
BUG();
|
||||
error("internal error: unknown parser state %d near byte %d",
|
||||
state, i);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user