[U-Boot] [PATCH 2/3] test/fs: Check ext4 behaviour if dirent is first entry in directory block

Stefan Brüns stefan.bruens at rwth-aachen.de
Sun Sep 11 22:46:05 CEST 2016


This is a regression test for a crash happening if the first dirent
in the block matches. Code tried to access a predecessor entry which
does not exist.
The crash happened for any block, but "." is always the first entry in
the first directory block and thus easy to check for.

Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
 test/fs/fs-test.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh
index 12450ed..cb2a765 100755
--- a/test/fs/fs-test.sh
+++ b/test/fs/fs-test.sh
@@ -291,6 +291,12 @@ ${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_WRITE
 md5sum $addr \$filesize
 setenv filesize
 #
+
+# Next test case checks writing a file whose dirent
+# is the first in the block, which is always true for "."
+# The write should fail, but the lookup should work
+# Test Case 12 - Check directory traversal
+${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}. 0x10
 reset
 
 EOF
@@ -471,6 +477,11 @@ function check_results() {
 	pass_fail "TC11: 1MB write to $5 - write succeeded"
 	check_md5 "Test Case 11b " "$1" "$2" 1 \
 		"TC11: 1MB write to $5 - content verified"
+
+	# Check lookup of 'dot' directory
+	grep -A5 "Test Case 12 " "$1" | \
+		egrep -q 'Unable to write file'
+	pass_fail "TC12: 1MB write to . - write denied"
 	echo "** End $1"
 }
 
-- 
2.10.0



More information about the U-Boot mailing list