2023-07-14 01:38:46

by Li Dongyang

[permalink] [raw]
Subject: [PATCH] e2image: correct group descriptors size in ext2fs_image_super_read()

From: Emoly Liu <[email protected]>

In function ext2fs_image_super_read(), the size of block group
descriptors should be (fs->blocksize * fs->desc_blocks), but not
(fs->blocksize * fs->group_desc_count).

Signed-off-by: Emoly Liu <[email protected]>
---
lib/ext2fs/imager.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index 23290a6a..16b09770 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -299,7 +299,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,
ssize_t actual, size;
errcode_t retval;

- size = (ssize_t)fs->blocksize * (fs->group_desc_count + 1);
+ size = (ssize_t)fs->blocksize * (fs->desc_blocks + 1);
buf = malloc(size);
if (!buf)
return ENOMEM;
@@ -323,7 +323,7 @@ errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd,
memcpy(fs->super, buf, SUPERBLOCK_SIZE);

memcpy(fs->group_desc, buf + fs->blocksize,
- (ssize_t)fs->blocksize * fs->group_desc_count);
+ (ssize_t)fs->blocksize * fs->desc_blocks);

retval = 0;

--
2.41.0



2023-07-20 22:55:01

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] e2image: correct group descriptors size in ext2fs_image_super_read()

On Jul 13, 2023, at 6:59 PM, Li Dongyang <[email protected]> wrote:
>
> From: Emoly Liu <[email protected]>
>
> In function ext2fs_image_super_read(), the size of block group
> descriptors should be (fs->blocksize * fs->desc_blocks), but not
> (fs->blocksize * fs->group_desc_count).
>
> Signed-off-by: Emoly Liu <[email protected]>

Reviewed-by: Andreas Dilger <[email protected]>

Cheers, Andreas






Attachments:
signature.asc (890.00 B)
Message signed with OpenPGP

2024-02-08 15:54:13

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2image: correct group descriptors size in ext2fs_image_super_read()


On Fri, 14 Jul 2023 10:59:58 +1000, Li Dongyang wrote:
> In function ext2fs_image_super_read(), the size of block group
> descriptors should be (fs->blocksize * fs->desc_blocks), but not
> (fs->blocksize * fs->group_desc_count).
>
>

Applied, thanks!

[1/1] e2image: correct group descriptors size in ext2fs_image_super_read()
commit: 633ab26eefe1b037eaba82d9a3555eb712c82345

(Note: this patch was white-space damaged so I had to apply it by hand.)

Best regards,
--
Theodore Ts'o <[email protected]>