Skip to contentSkip to conversation

erofs-utils: fix `-Ededupe` crash without fragments enabled

PATCH In review Gao Xiang 2 participants 2 messages May 6, 2023 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: fix `-Ededupe` crash without fragments enabled

Otherwise, an unexpected segfault will happen since
EROFS_FEATURE_INCOMPAT_FRAGMENTS and
EROFS_FEATURE_INCOMPAT_DEDUPE share the same bit.

Fixes 18fbf7d12e4f ("erofs-utils: build xattrs upon extra long name prefixes")
---
 lib/xattr.c | 1 +
 mkfs/main.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
lib/xattr.c +1 -0
index 5e9e413..9c87227 100644
@@ -646,6 +646,7 @@ int erofs_xattr_write_name_prefixes(FILE *f)
 		if (fseek(f, offset, SEEK_SET))
 			return -errno;
 	}
+	cfg.c_fragments = true;
 	erofs_sb_set_fragments();
 	erofs_sb_set_xattr_prefixes();
 	return 0;
mkfs/main.c +1 -1
index 467ea86..ddedfde 100644
@@ -903,7 +903,7 @@ int main(int argc, char **argv)
 	}
 
 	packed_nid = 0;
-	if (erofs_sb_has_fragments()) {
+	if (cfg.c_fragments && erofs_sb_has_fragments()) {
 		erofs_update_progressinfo("Handling packed_file ...");
 		packed_inode = erofs_mkfs_build_packedfile();
 		if (IS_ERR(packed_inode)) {
Signature · 1 line
2.24.4
#1 lore raw
Quoted 28 lines · Gao Xiang

Otherwise, an unexpected segfault will happen since
EROFS_FEATURE_INCOMPAT_FRAGMENTS and
EROFS_FEATURE_INCOMPAT_DEDUPE share the same bit.

Fixes 18fbf7d12e4f ("erofs-utils: build xattrs upon extra long name prefixes")
---
 lib/xattr.c | 1 +
 mkfs/main.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
lib/xattr.c +1 -0
index 5e9e413..9c87227 100644
@@ -646,6 +646,7 @@ int erofs_xattr_write_name_prefixes(FILE *f)
 		if (fseek(f, offset, SEEK_SET))
 			return -errno;
 	}
+	cfg.c_fragments = true;
 	erofs_sb_set_fragments();
 	erofs_sb_set_xattr_prefixes();
 	return 0;
mkfs/main.c +0 -0
index 467ea86..ddedfde 100644

mkfs/main.c int main(int argc, char **argv) · line 909

Quoted 8 lines
mkfs/main.c +1 -1
@@ -903,7 +903,7 @@ int main(int argc, char **argv)
 	}
 
 	packed_nid = 0;
-	if (erofs_sb_has_fragments()) {
+	if (cfg.c_fragments && erofs_sb_has_fragments()) {
 		erofs_update_progressinfo("Handling packed_file ...");
 		packed_inode = erofs_mkfs_build_packedfile();
 		if (IS_ERR(packed_inode)) {

We have cfg.c_extra_ea_name_prefixes now. How about

	if ((cfg.c_fragments || cfg.c_extra_ea_name_prefixes) &&
            erofs_sb_has_fragments())
Signature · 2 lines
Thanks,
Jingbo