VirtualBox

Changeset 66709 in vbox for trunk


Ignore:
Timestamp:
Apr 27, 2017 10:24:09 PM (8 years ago)
Author:
vboxsync
Message:

fatvfs.cpp: Check for invalid long name characters as well as a few names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/filesystem/fatvfs.cpp

    r66708 r66709  
    394394*   Global Variables                                                                                                             *
    395395*********************************************************************************************************************************/
    396 /** Codepage 437 translation table with invalid 8.3 characters marked as 0xffff.
     396/**
     397 * Codepage 437 translation table with invalid 8.3 characters marked as 0xffff or 0xfffe.
     398 *
     399 * The 0xfffe notation is used for characters that are valid in long file names but not short.
     400 *
    397401 * @remarks The valid first 128 entries are 1:1 with unicode.
    398402 * @remarks Lower case characters are all marked invalid.
     
    402406    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
    403407    0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
    404     0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0xffff, 0xffff, 0xffff, 0x002d, 0xffff, 0xffff,
    405     0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
     408    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0xffff, 0xfffe, 0xfffe, 0x002d, 0xfffe, 0xffff,
     409    0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0xffff, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xffff,
    406410    0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
    407     0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0xffff, 0xffff, 0xffff, 0x005e, 0x005f,
    408     0x0060, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
    409     0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x007e, 0xffff,
     411    0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005a, 0xfffe, 0xffff, 0xfffe, 0x005e, 0x005f,
     412    0x0060, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe,
     413    0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xfffe, 0xffff, 0xffff, 0xffff, 0x007e, 0xffff,
    410414    0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
    411415    0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9, 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
     
    26442648static int rtFsFatDir_ValidateLongName(PCRTUTF16 pwszEntry, size_t cwc)
    26452649{
     2650    /* Length limitation. */
    26462651    if (cwc <= RTFSFAT_MAX_LFN_CHARS)
    26472652    {
    2648         RT_NOREF(pwszEntry);
    2649         /** @todo check for invalid characters. */
     2653        /* Character set limitations. */
     2654        for (size_t off = 0; off < cwc; off++)
     2655        {
     2656            RTUTF16 wc = pwszEntry[off];
     2657            if (wc < 128)
     2658            {
     2659                if (g_awchFatCp437Chars[wc] <= UINT16_C(0xfffe))
     2660                { /* likely */ }
     2661                else
     2662                    return VERR_INVALID_NAME;
     2663            }
     2664        }
     2665
     2666        /* Name limitations. */
     2667        if (   cwc == 1
     2668            && pwszEntry[0] == '.')
     2669            return VERR_INVALID_NAME;
     2670        if (   cwc == 2
     2671            && pwszEntry[0] == '.'
     2672            && pwszEntry[1] == '.')
     2673            return VERR_INVALID_NAME;
     2674
     2675        /** @todo Check for more invalid names, also in the 8.3 case! */
    26502676        return VINF_SUCCESS;
    26512677    }
     
    26542680
    26552681
     2682/**
     2683 * Worker for rtFsFatDir_GenerateShortName.
     2684 */
    26562685static void rtFsFatDir_CopyShortName(char *pszDst, uint32_t cchDst, const char *pszSrc, size_t cchSrc, char chPad)
    26572686{
     
    31553184        }
    31563185    }
    3157     else
    3158         rc = VERR_NET_NOT_UNIQUE_NAME;
    31593186    return rc;
    31603187}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette