[U-Boot] [PATCH 3/3] test/fs: Check writes using "." (same dir) relative path

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


<path>/<fname> and <path>/./<fname> should reference the same file.

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

diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh
index cb2a765..46975ec 100755
--- a/test/fs/fs-test.sh
+++ b/test/fs/fs-test.sh
@@ -297,6 +297,23 @@ setenv filesize
 # The write should fail, but the lookup should work
 # Test Case 12 - Check directory traversal
 ${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}. 0x10
+
+# Read 1MB from small file
+${PREFIX}load host${SUFFIX} $addr ${FPATH}$FILE_SMALL
+# Write it via "same directory", i.e. "." dirent
+# Test Case 13a - Check directory traversal
+${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}./${FILE_WRITE}2 \$filesize
+mw.b $addr 00 100
+${PREFIX}load host${SUFFIX} $addr ${FPATH}./${FILE_WRITE}2
+# Test Case 13b - Check md5 of written to is same as the one read from
+md5sum $addr \$filesize
+setenv filesize
+mw.b $addr 00 100
+${PREFIX}load host${SUFFIX} $addr ${FPATH}${FILE_WRITE}2
+# Test Case 13c - Check md5 of written to is same as the one read from
+md5sum $addr \$filesize
+setenv filesize
+#
 reset
 
 EOF
@@ -482,6 +499,16 @@ function check_results() {
 	grep -A5 "Test Case 12 " "$1" | \
 		egrep -q 'Unable to write file'
 	pass_fail "TC12: 1MB write to . - write denied"
+
+	# Check directory traversal
+	grep -A6 "Test Case 13a " "$1" | \
+		egrep -q '1048576 bytes written|update journal'
+	pass_fail "TC13: 1MB write to ./$5 - write succeeded"
+	check_md5 "Test Case 13b " "$1" "$2" 1 \
+		"TC13: 1MB read from ./$5 - content verified"
+	check_md5 "Test Case 13c " "$1" "$2" 1 \
+		"TC13: 1MB read from $5 - content verified"
+
 	echo "** End $1"
 }
 
-- 
2.10.0



More information about the U-Boot mailing list