Ticket #2987: 0001-Fix-issue-that-msdos_dir_read-didn-t-reset-an-output.patch

File 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)
  • cpukit/libfs/src/dosfs/msdos_dir.c

    diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c b/cpukit/libfs/src/dosfs/msdos_dir.c
    index 40f9f0f..9f8b57e 100644
    a b msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) 
    285285                        lfn_checksum != msdos_lfn_checksum(entry))
    286286                        lfn_start = FAT_FILE_SHORT_NAME;
    287287
     288                    /* Re-initialise string size, because
     289                     * the converter below sets the new
     290                     * string length here.
     291                     *
     292                     * If the SFN checksum does not match
     293                     * the LFN checksum, lfn_start will be
     294                     * set to FAT_SHORT_FILE_NAME (above).
     295                     * So same goes for the conversion
     296                     * below - if size is not reinitialised,
     297                     * file name will be truncated to the
     298                     * length of the (invalid) LFN length.
     299                     * */
     300                    string_size = sizeof(tmp_dirent.d_name);
    288301                    eno = (*convert_handler->utf16_to_utf8) (
    289302                        converter,
    290303                        lfn_buf,
    msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) 
    302315
    303316                if (lfn_start == FAT_FILE_SHORT_NAME)
    304317                {
     318
    305319                    /*
    306320                     * convert dir entry from fixed 8+3 format (without dot)
    307321                     * to 0..8 + 1dot + 0..3 format
    308322                     */
    309323                    tmp_dirent.d_namlen = msdos_format_dirent_with_dot(
    310324                        sfn_buf, entry); /* src text */
     325
     326                    string_size = sizeof(tmp_dirent.d_name);
    311327                    eno = (*convert_handler->codepage_to_utf8) (
    312328                        converter,
    313329                        sfn_buf,
    msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count) 
    325341                }
    326342
    327343                if ( cmpltd >= 0 ) {
     344
    328345                    memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent));
    329346
    330347                    iop->offset = iop->offset + sizeof(struct dirent);