erofs-utils: tar: guard NULL hardlink targets
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.
Signed-off-by Vansh Choudhary <[email protected]>
--- lib/tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tar.c +1 -1
@@ -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
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 dereferencingd2->type.Signed-off-by Vansh Choudhary <[email protected]>
Can we work out some testcases in experimental-tests?
Thanks,
Gao Xiang
PATCH 1/1 erofs-utils: tests: add test for malformed tar hardlink targets
Add a regression test for malformed tar hardlink targets.
Signed-off-by Vansh Choudhary <[email protected]>
--- 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
@@ -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
@@ -0,0 +1,2 @@ +QA output created by 029 +Silence is golden
tests/src/Makefile.am +3 -0
@@ -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