#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)

0001-Fix-issue-that-msdos_dir_read-didn-t-reset-an-output.patch (2.2 KB) - added by slemstick on 04/09/17 at 10:33:41.

Download all attachments as: .zip

Change History (10)

comment:1 Changed on 04/11/17 at 00:43:35 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 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:3 Changed on 06/12/17 at 07:32:58 by Sebastian Huber

Without a real name I cannot apply this patch.

comment:4 Changed on 08/24/17 at 09:56:36 by Sebastian Huber

Owner: set to Sebastian Huber
Status: newassigned

comment:5 Changed on 08/24/17 at 10:03:56 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 09/06/17 at 11:22:03 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 09/06/17 at 11:24:30 by Sebastian Huber

Milestone: 4.12.04.11.3
Version: 4.124.11

comment:8 Changed on 09/06/17 at 11:24:52 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 10/10/17 at 06:50:58 by Sebastian Huber

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