mirror of
https://xff.cz/git/u-boot/
synced 2025-10-18 00:11:48 +02:00
ext4: recover from filesystem corruption when reading
Some fixes when reading EXT files and directory entries were identified after using e2fuzz to corrupt an EXT3 filesystem: - Stop reading directory entries if the offset becomes badly aligned. - Avoid overwriting memory by clamping the length used to zero the buffer in ext4fs_read_file. Also sanity check blocksize. Signed-off-by: Ian Ray <ian.ray@ge.com> Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk> Reviewed-by: Stefano Babic <sbabic@denx.de>
This commit is contained in:
@@ -660,6 +660,11 @@ static int search_dir(struct ext2_inode *parent_inode, char *dirname)
|
||||
|
||||
offset = 0;
|
||||
do {
|
||||
if (offset & 3) {
|
||||
printf("Badly aligned ext2_dirent\n");
|
||||
break;
|
||||
}
|
||||
|
||||
dir = (struct ext2_dirent *)(block_buffer + offset);
|
||||
direntname = (char*)(dir) + sizeof(struct ext2_dirent);
|
||||
|
||||
@@ -880,6 +885,11 @@ static int unlink_filename(char *filename, unsigned int blknr)
|
||||
|
||||
offset = 0;
|
||||
do {
|
||||
if (offset & 3) {
|
||||
printf("Badly aligned ext2_dirent\n");
|
||||
break;
|
||||
}
|
||||
|
||||
previous_dir = dir;
|
||||
dir = (struct ext2_dirent *)(block_buffer + offset);
|
||||
direntname = (char *)(dir) + sizeof(struct ext2_dirent);
|
||||
|
Reference in New Issue
Block a user