VirtualBox

Changeset 30371 in vbox


Ignore:
Timestamp:
Jun 22, 2010 12:29:19 PM (15 years ago)
Author:
vboxsync
Message:

RTFsQueryType/win: Fix for FileSystemName not being terminated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/fs-win.cpp

    r30365 r30371  
    338338 * Internal helper for comparing a WCHAR string with a char string.
    339339 *
    340  * @returns 0 if equal, -1 if @a psz1 < @a psz2, 1 if @a psz1 < @a psz2.
    341  * @param   pwsz1               The first string.
    342  * @param   psz2                The second string.
    343  */
    344 static int rtFsWinCmpUtf16(WCHAR const *pwsz1, const char *psz2)
    345 {
    346     for (;;)
     340 * @returns @c true if equal, @c false if not.
     341 * @param   pwsz1               The first string.
     342 * @param   cb1                 The length of the first string, in bytes.
     343 * @param   psz2                The second string.
     344 * @param   cch2                The length of the second string.
     345 */
     346static bool rtFsWinAreEqual(WCHAR const *pwsz1, size_t cch1, const char *psz2, size_t cch2)
     347{
     348    if (cch1 != cch2 * 2)
     349        return false;
     350    while (cch2-- > 0)
    347351    {
    348352        unsigned ch1 = *pwsz1++;
    349353        unsigned ch2 = (unsigned char)*psz2++;
    350354        if (ch1 != ch2)
    351             return ch1 < ch2 ? -1 : 1;
    352         if (!ch1)
    353             return 0;
    354     }
     355            return false;
     356    }
     357    return true;
    355358}
    356359
     
    390393            {
    391394                PFILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)abBuf;
    392 
    393                 if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "NTFS"))
     395                if (pFsAttrInfo->FIleSystemNameLength)
     396                {
     397                }
     398#define IS_FS(szName) \
     399    rtFsWinAreEqual(pFsAttrInfo->FileSystemName, pFsAttrInfo->FIleSystemNameLength, szName, sizeof(szName) - 1)
     400                if (IS_FS("NTFS"))
    394401                    *penmType = RTFSTYPE_NTFS;
    395                 else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "FAT"))
     402                else if (IS_FS("FAT"))
    396403                    *penmType = RTFSTYPE_FAT;
    397                 else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "FAT32"))
     404                else if (IS_FS("FAT32"))
    398405                    *penmType = RTFSTYPE_FAT;
    399                 else if (!rtFsWinCmpUtf16(pFsAttrInfo->FileSystemName, "VBoxSharedFolderFS"))
     406                else if (IS_FS("VBoxSharedFolderFS"))
    400407                    *penmType = RTFSTYPE_VBOXSHF;
     408#undef IS_FS
    401409            }
    402410            else
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