VirtualBox

Changeset 3008 in kBuild for trunk/src/lib/nt/ntstat.c


Ignore:
Timestamp:
Nov 6, 2016 4:50:03 PM (8 years ago)
Author:
bird
Message:

birdStatHandle*: Don't get the filename it's a directory, birdFileInfoToMode won't need it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/ntstat.c

    r3007 r3008  
    6969static int birdIsFileExecutable(const char *pszName)
    7070{
    71     const char     *pszExt = NULL;
    72     char            szExt[8];
    73     size_t          cchExt;
    74     unsigned        i;
    75     char            ch;
    76 
    77     /* Look for a 3 char extension. */
    78     ch = *pszName++;
    79     if (!ch)
    80         return 0;
    81 
    82     while ((ch = *pszName++) != '\0')
    83         if (ch == '.')
    84             pszExt = pszName;
    85 
    86     if (!pszExt)
    87         return 0;
    88     pszExt++;
    89     cchExt = pszName - pszExt;
    90     if (cchExt != 3)
    91         return 0;
    92 
    93     /* Copy the extension out and lower case it.  Fail immediately on non-alpha chars. */
    94     for (i = 0; i < cchExt; i++, pszExt++)
    95     {
    96         ch = *pszExt;
    97         if (ch >= 'a' && ch <= 'z')
    98         { /* likely */ }
    99         else if (ch >= 'A' && ch <= 'Z')
    100             ch += 'a' - 'A';
    101         else
     71    if (pszName)
     72    {
     73        const char     *pszExt = NULL;
     74        char            szExt[8];
     75        size_t          cchExt;
     76        unsigned        i;
     77        char            ch;
     78
     79        /* Look for a 3 char extension. */
     80        ch = *pszName++;
     81        if (!ch)
    10282            return 0;
    103         szExt[i] = ch;
    104     }
    105     szExt[i] = '\0';
    106 
    107     return birdIsExecutableExtension(szExt);
     83
     84        while ((ch = *pszName++) != '\0')
     85            if (ch == '.')
     86                pszExt = pszName;
     87
     88        if (!pszExt)
     89            return 0;
     90        pszExt++;
     91        cchExt = pszName - pszExt;
     92        if (cchExt != 3)
     93            return 0;
     94
     95        /* Copy the extension out and lower case it.  Fail immediately on non-alpha chars. */
     96        for (i = 0; i < cchExt; i++, pszExt++)
     97        {
     98            ch = *pszExt;
     99            if (ch >= 'a' && ch <= 'z')
     100            { /* likely */ }
     101            else if (ch >= 'A' && ch <= 'Z')
     102                ch += 'a' - 'A';
     103            else
     104                return 0;
     105            szExt[i] = ch;
     106        }
     107        szExt[i] = '\0';
     108
     109        return birdIsExecutableExtension(szExt);
     110    }
     111
     112    return 0;
    108113}
    109114
     
    389394    }
    390395
    391     if (MY_NT_SUCCESS(rcNt) && !pszPath && !pwszPath)
     396    if (   MY_NT_SUCCESS(rcNt)
     397        && !pszPath
     398        && !pwszPath
     399        && !(BasicInfo.FileAttributes & FILE_ATTRIBUTE_DIRECTORY))
    392400    {
    393401        cbNameInfo = 0x10020;
Note: See TracChangeset for help on using the changeset viewer.

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