Index: cpukit/libfs/src/dosfs/msdos_dir.c
===================================================================
--- cpukit/libfs/src/dosfs/msdos_dir.c	(revision 2ed53cb9820f6830b398502615e35cea09854180)
+++ cpukit/libfs/src/dosfs/msdos_dir.c	(revision e1c3dc090953876079946b0d29d97ff09d1ecc85)
@@ -73,5 +73,5 @@
     fat_file_fd_t     *tmp_fat_fd = NULL;
     struct dirent      tmp_dirent;
-    size_t             tmp_lfn_len = 0;
+    size_t             lfn_len = 0;
     uint16_t          *lfn_buf = converter->buffer.data;
     char              *sfn_buf = converter->buffer.data;
@@ -86,5 +86,4 @@
     uint8_t            lfn_checksum = 0;
     int                lfn_entries = 0;
-    size_t             string_size = sizeof(tmp_dirent.d_name);
     bool               is_first_entry;
 
@@ -186,5 +185,5 @@
                     lfn_entries = (*MSDOS_DIR_ENTRY_TYPE(entry) &
                                    MSDOS_LAST_LONG_ENTRY_MASK);
-                    tmp_lfn_len = 0;
+                    lfn_len = 0;
                     lfn_checksum = *MSDOS_DIR_LFN_CHECKSUM(entry);
                     memset (tmp_dirent.d_name, 0, sizeof(tmp_dirent.d_name));
@@ -221,5 +220,5 @@
                 lfn_entries--;
                 offset_lfn = lfn_entries * MSDOS_LFN_LEN_PER_ENTRY;
-                tmp_lfn_len += msdos_get_utf16_string_from_long_entry (
+                lfn_len += msdos_get_utf16_string_from_long_entry (
                   entry,
                   &lfn_buf[offset_lfn],
@@ -282,25 +281,28 @@
                 if (lfn_start != FAT_FILE_SHORT_NAME)
                 {
-                    if (lfn_entries ||
-                        lfn_checksum != msdos_lfn_checksum(entry))
-                        lfn_start = FAT_FILE_SHORT_NAME;
-
-                    eno = (*convert_handler->utf16_to_utf8) (
-                        converter,
-                        lfn_buf,
-                        tmp_lfn_len,
-                        (uint8_t*)(&tmp_dirent.d_name[0]),
-                        &string_size);
-                    if (eno == 0) {
-                      tmp_dirent.d_namlen                    = string_size;
-                      tmp_dirent.d_name[tmp_dirent.d_namlen] = '\0';
-                    }
-                    else {
+                    if (lfn_entries == 0 &&
+                        lfn_checksum == msdos_lfn_checksum(entry)) {
+                        size_t len = sizeof(tmp_dirent.d_name) - 1;
+
+                        eno = (*convert_handler->utf16_to_utf8) (
+                            converter,
+                            lfn_buf,
+                            lfn_len,
+                            (uint8_t *) &tmp_dirent.d_name[0],
+                            &len);
+                        if (eno == 0) {
+                            tmp_dirent.d_namlen = len;
+                            tmp_dirent.d_name[len] = '\0';
+                        } else {
+                            lfn_start = FAT_FILE_SHORT_NAME;
+                        }
+                    } else {
                         lfn_start = FAT_FILE_SHORT_NAME;
                     }
                 }
 
-                if (lfn_start == FAT_FILE_SHORT_NAME)
-                {
+                if (lfn_start == FAT_FILE_SHORT_NAME) {
+                    size_t len = sizeof(tmp_dirent.d_name) - 1;
+
                     /*
                      * convert dir entry from fixed 8+3 format (without dot)
@@ -313,11 +315,10 @@
                         sfn_buf,
                         tmp_dirent.d_namlen,
-                        (uint8_t*)(&tmp_dirent.d_name[0]),
-                        &string_size);
+                        (uint8_t *) &tmp_dirent.d_name[0],
+                        &len);
                     if ( 0 == eno ) {
-                      tmp_dirent.d_namlen                    = string_size;
-                      tmp_dirent.d_name[tmp_dirent.d_namlen] = '\0';
-                    }
-                    else {
+                      tmp_dirent.d_namlen = len;
+                      tmp_dirent.d_name[len] = '\0';
+                    } else {
                         cmpltd = -1;
                         errno  = eno;
