[rtems commit] dosfs: Fix msdos_find_file_in_directory()

Sebastian Huber sebh at rtems.org
Tue Feb 14 07:10:07 UTC 2017


Module:    rtems
Branch:    4.11
Commit:    04684cbc436f79339854c4bca22f65bb947f6949
Changeset: http://git.rtems.org/rtems/commit/?id=04684cbc436f79339854c4bca22f65bb947f6949

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Feb 13 15:13:02 2017 +0100

dosfs: Fix msdos_find_file_in_directory()

For a filename match the entry must match without anything remaining.

Update #2908.

---

 cpukit/libfs/src/dosfs/msdos_misc.c     |  2 +-
 testsuites/fstests/fsdosfsname01/init.c | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_misc.c b/cpukit/libfs/src/dosfs/msdos_misc.c
index 76dff43..39f6ca2 100644
--- a/cpukit/libfs/src/dosfs/msdos_misc.c
+++ b/cpukit/libfs/src/dosfs/msdos_misc.c
@@ -1539,7 +1539,7 @@ msdos_find_file_in_directory (
 
                         if (lfn_entry || (lfn_checksum != cs))
                             entry_matched = false;
-                        else {
+                        else if (filename_size_remaining == 0) {
                             filename_matched = true;
                             rc = msdos_on_entry_found (
                                 fs_info,
diff --git a/testsuites/fstests/fsdosfsname01/init.c b/testsuites/fstests/fsdosfsname01/init.c
index c5af7fc..4d06958 100644
--- a/testsuites/fstests/fsdosfsname01/init.c
+++ b/testsuites/fstests/fsdosfsname01/init.c
@@ -1071,6 +1071,22 @@ static void test_compatibility( void )
   rtems_test_assert( rc == 0 );
 }
 
+static void test_end_of_string_matches( void )
+{
+  int rc;
+
+  rc = mkdir( MOUNT_DIR "/lib.beam", S_IRWXU | S_IRWXG | S_IRWXO );
+  rtems_test_assert( rc == 0 );
+
+  errno = 0;
+  rc = unlink( MOUNT_DIR "/proc_lib.beam" );
+  rtems_test_assert( rc == -1 );
+  rtems_test_assert( errno == ENOENT );
+
+  rc = unlink( MOUNT_DIR "/lib.beam" );
+  rtems_test_assert( rc == 0 );
+}
+
 /*
  * Main test method
  */
@@ -1129,6 +1145,8 @@ static void test( void )
     "/dev/rdb",
     NULL);
 
+  test_end_of_string_matches();
+
   rc = unmount( MOUNT_DIR );
   rtems_test_assert( rc == 0 );
 
@@ -1197,6 +1215,8 @@ static void test( void )
     "/dev/rdb",
     &mount_opts[1]);
 
+  test_end_of_string_matches();
+
   rc = unmount( MOUNT_DIR );
   rtems_test_assert( rc == 0 );
 
@@ -1260,6 +1280,8 @@ static void test( void )
     "/dev/rdc",
     &mount_opts[1]);
 
+  test_end_of_string_matches();
+
   rc = unmount( MOUNT_DIR );
   rtems_test_assert( rc == 0 );
 




More information about the vc mailing list