All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libext2fs: Extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems.
@ 2020-01-10  8:52 Anatoly Pugachev
  2020-01-10 17:34 ` Theodore Y. Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Anatoly Pugachev @ 2020-01-10  8:52 UTC (permalink / raw)
  To: linux-ext4; +Cc: Theodore Ts'o


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@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-11  0:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10  8:52 [PATCH] libext2fs: Extends commit c9a8c53b, with the same fix for ext2fs_flush2() and ext2fs_image_super_write() on a Big Endian systems Anatoly Pugachev
2020-01-10 17:34 ` Theodore Y. Ts'o
2020-01-11  0:13   ` Anatoly Pugachev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.