libext2fs: extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems. As follow-up to previous discussion 'dumpe2fs / mke2fs sigserv on sparc64' Used find for files which refer to: e2fsprogs.git$ find . -name \*.c | xargs grep -cl 'gdp = ext2fs_group_desc' ./lib/ext2fs/closefs.c ./lib/ext2fs/openfs.c ./lib/ext2fs/imager.c And applied the same check for a null pointer. Tested on a debian linux with sparc64 LDOM and ppc64 LPAR. Fixes sigserv with test suite in "i_bitmaps" test. Signed-off-by: Anatoly Pugachev <matorola@xxxxxxxxx> Signed-off-by: Theodore Ts'o <tytso@xxxxxxx> --- lib/ext2fs/closefs.c | 3 ++- lib/ext2fs/imager.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 1d4d5b7f..58fdd5c6 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -339,7 +339,8 @@ errcode_t ext2fs_flush2(ext2_filsys fs, int flags) ext2fs_swap_super(super_shadow); for (j = 0; j < fs->group_desc_count; j++) { gdp = ext2fs_group_desc(fs, group_shadow, j); - ext2fs_swap_group_desc2(fs, gdp); + if (gdp) + ext2fs_swap_group_desc2(fs, gdp); } #else super_shadow = fs->super; diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index 7fd06f74..b40fd826 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -245,7 +245,8 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, gdp = (struct ext2_group_desc *) cp; for (j=0; j < groups_per_block*fs->desc_blocks; j++) { gdp = ext2fs_group_desc(fs, fs->group_desc, j); - ext2fs_swap_group_desc2(fs, gdp); + if (gdp) + ext2fs_swap_group_desc2(fs, gdp); } #endif @@ -257,7 +258,8 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, gdp = (struct ext2_group_desc *) cp; for (j=0; j < groups_per_block*fs->desc_blocks; j++) { gdp = ext2fs_group_desc(fs, fs->group_desc, j); - ext2fs_swap_group_desc2(fs, gdp); + if (gdp) + ext2fs_swap_group_desc2(fs, gdp); } #endif -- 2.25.0.rc1