#2987 closed defect (fixed)

fat: msdos_dir_read(..) doesn't reset conversion output string length

Reported by: slemstick Owned by: Sebastian Huber
Priority: normal Milestone: 4.11.3
Component: fs/fat Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

msdos_dir_read(..) uses a conversion function, convert_handler->utf16_to_utf8, to convert LFN directory entry names in utf16 format to utf8.

However, the conversion handler sets the string length of the output utf8 string as well. That variable: string_size in msdos_dir_read(..) is never re-initialised in the search algorithm. When the volume becomes sufficiently fragmented, de-allocated LFN directory entry checksums will cause the filename search algorithm to fail, effectively breaking the current attempt to concatenate directory entry filename chunks, but the output string size is now much shorter (10 characters, where it should be sizeof(tmp_dirent.d_name)). Consequently, msdos_dir_read(..) will continue to parse directory entries with a much smaller output string size.

The end result is that attempts to read file names from a directory will output truncated file names (for example, readdir() will "work" as normal but the output filenames are too short). Any attempt to open these truncated file names will, of course, fail.

Attachments (1)

Change History (10)

comment:1 Changed on Apr 11, 2017 at 12:43:35 AM by Gedare Bloom

Please remove the spurious whitespace changes, add "Closes #2987." Into the commit message, and format a friendly short commit message that specifies the rtems subsystem first, e.g. "libfs/dosfs: ..."
Please see Developer/Git

comment:2 Changed on May 11, 2017 at 7:31:02 AM by Sebastian Huber

Milestone: 4.124.12.0

comment:3 Changed on Jun 12, 2017 at 7:32:58 AM by Sebastian Huber

Without a real name I cannot apply this patch.

comment:4 Changed on Aug 24, 2017 at 9:56:36 AM by Sebastian Huber

Owner: set to Sebastian Huber
Status: newassigned

comment:5 Changed on Aug 24, 2017 at 10:03:56 AM by Sebastian Huber

Component: Generalfilesystem
Summary: msdos_dir_read(..) doesn't reset conversion output string lengthfat: msdos_dir_read(..) doesn't reset conversion output string length

comment:6 Changed on Sep 6, 2017 at 11:22:03 AM by Sebastian Huber <sebastian.huber@…>

In 34dda604/rtems:

dosfs: Fix msdos_dir_read()

Set a proper name buffer length for each converter invocation.

Update #2987.

comment:7 Changed on Sep 6, 2017 at 11:24:30 AM by Sebastian Huber

Milestone: 4.12.04.11.3
Version: 4.124.11

comment:8 Changed on Sep 6, 2017 at 11:24:52 AM by Sebastian Huber <sebastian.huber@…>

Resolution: fixed
Status: assignedclosed

In e1c3dc09/rtems:

dosfs: Fix msdos_dir_read()

Set a proper name buffer length for each converter invocation.

Close #2987.

comment:9 Changed on Oct 10, 2017 at 6:50:58 AM by Sebastian Huber

Component: fsfs/fat
Note: See TracTickets for help on using tickets.