Skip to contentSkip to conversation

erofs-utils: tar: guard NULL hardlink targets

PATCH In review Vansh Choudhary 2 participants 3 messages Mar 26 – Mar 27 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: tar: guard NULL hardlink targets

erofs_rebuild_get_dentry() can return NULL for empty or dot-style paths. Treat that like an unresolved hardlink target instead of dereferencing d2->type.

---
 lib/tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tar.c +1 -1
index 24e0413..4eb0060 100644
@@ -1033,7 +1033,7 @@ out_eot:
 			ret = PTR_ERR(d2);
 			goto out;
 		}
-		if (d2->type == EROFS_FT_UNKNOWN) {
+		if (!d2 || d2->type == EROFS_FT_UNKNOWN) {
 			ret = -ENOENT;
 			goto out;
 		}
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Vansh Choudhary

erofs_rebuild_get_dentry() can return NULL for empty or dot-style paths. Treat that like an unresolved hardlink target instead of dereferencing d2->type.

Can we work out some testcases in experimental-tests?

Thanks,
Gao Xiang

#2 lore raw

PATCH 1/1 erofs-utils: tests: add test for malformed tar hardlink targets

Add a regression test for malformed tar hardlink targets.

---
 tests/Makefile.am     |   3 +
 tests/erofs/029       |  54 ++++++++++++++
 tests/erofs/029.out   |   2 +
 tests/src/Makefile.am |   3 +
 tests/src/badtar.c    | 159 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 221 insertions(+)
 create mode 100755 tests/erofs/029
 create mode 100644 tests/erofs/029.out
 create mode 100644 tests/src/badtar.c
tests/Makefile.am +3 -0
index e376d6a..1e9726f 100644
@@ -122,6 +122,9 @@ TESTS += erofs/027
 # 028 - test inode page cache sharing functionality
 TESTS += erofs/028
 
+# 029 - regression test for malformed tar hardlink targets
+TESTS += erofs/029
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/erofs/029 new file +54 -0

54 lines not on this page · raw message

tests/erofs/029.out new file +2 -0
new file mode 100644
index 0000000..8ee6db4
@@ -0,0 +1,2 @@
+QA output created by 029
+Silence is golden
tests/src/Makefile.am +3 -0
index 16de41a..4a02509 100644
@@ -15,3 +15,6 @@ badlz4_SOURCES = badlz4.c
 badlz4_CFLAGS = ${liblz4_CFLAGS}
 badlz4_LDADD = ${liblz4_LIBS}
 endif
+
+check_PROGRAMS += badtar
+badtar_SOURCES = badtar.c
tests/src/badtar.c new file +159 -0

159 lines not on this page · raw message

Signature · 1 line
2.43.0