Blame SOURCES/0030-tests-t3000-resize-fs.sh-Add-very-deep-directory.patch

003ee8
From 599ce25c802fc1154ed619fde4249bb381430407 Mon Sep 17 00:00:00 2001
003ee8
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
003ee8
Date: Sun, 28 Feb 2016 15:36:11 +0000
003ee8
Subject: [PATCH 30/30] tests: t3000-resize-fs.sh: Add very deep directory
003ee8
003ee8
Create 500 deep directory tree, with longest name of 4000 characters, to
003ee8
the file system being resized to test the fix to prevent crash when
003ee8
resizing a FAT file system with such a long path.
003ee8
---
003ee8
 tests/t3000-resize-fs.sh | 16 ++++++++++++++++
003ee8
 1 file changed, 16 insertions(+)
003ee8
003ee8
diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
003ee8
index a79a307..608871c 100755
003ee8
--- a/tests/t3000-resize-fs.sh
003ee8
+++ b/tests/t3000-resize-fs.sh
003ee8
@@ -46,6 +46,13 @@ device_sectors_required=$(echo $default_end | sed 's/s$//')
003ee8
 # Ensure that $dev is large enough for this test
003ee8
 test $device_sectors_required -le $dev_n_sectors || fail=1
003ee8
 
003ee8
+# create mount point dir
003ee8
+mount_point="`pwd`/mnt"
003ee8
+mkdir "$mount_point" || fail=1
003ee8
+
003ee8
+# be sure to unmount upon interrupt, failure, etc.
003ee8
+cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; }
003ee8
+
003ee8
 for fs_type in hfs+ fat32 fat16; do
003ee8
   echo "fs_type=$fs_type"
003ee8
 
003ee8
@@ -69,6 +76,15 @@ for fs_type in hfs+ fat32 fat16; do
003ee8
   # create the file system
003ee8
   $mkfs_cmd ${dev}1 || fail=1
003ee8
 
003ee8
+  # create 500 deep directory tree with longest name 4000 characters
003ee8
+  # to catch core dump in libparted/fs/r/fat/count.c flag_traverse_dir()
003ee8
+  # overflowing 512 byte file_name local buffer.
003ee8
+  mount "${dev}1" "$mount_point" || fail=1
003ee8
+  cat /dev/null > exp
003ee8
+  ( cd "$mount_point"; for d in `seq 500`; do mkdir TESTDIR; cd TESTDIR; done ) > out
003ee8
+  compare exp out || fail=1   # Ensure no errors creating directory tree
003ee8
+  umount "${dev}1" || fail=1
003ee8
+
003ee8
   # NOTE: shrinking is the only type of resizing that works.
003ee8
   # resize that file system to be one cylinder (8MiB) smaller
003ee8
   fs-resize ${dev}1 0 $new_end > out 2>&1 || fail=1
003ee8
-- 
003ee8
2.5.0
003ee8