Changeset 2993 in kBuild
- Timestamp:
- Nov 1, 2016 10:41:26 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt/ntstat.c
r2985 r2993 46 46 static int birdIsExecutableExtension(const char *pszExt) 47 47 { 48 return !strcmp(pszExt, "exe") 49 || !strcmp(pszExt, "cmd") 50 || !strcmp(pszExt, "bat") 51 || !strcmp(pszExt, "vbs") 52 || !strcmp(pszExt, "com") 53 ; 48 switch (pszExt[0]) 49 { 50 default: 51 return 0; 52 53 case 'e': /* exe */ 54 return pszExt[1] == 'x' && pszExt[2] == 'e' && pszExt[3] == '\0'; 55 56 case 'b': /* bat */ 57 return pszExt[1] == 'a' && pszExt[2] == 't' && pszExt[3] == '\0'; 58 59 case 'v': /* vbs */ 60 return pszExt[1] == 'v' && pszExt[2] == 's' && pszExt[3] == '\0'; 61 62 case 'c': /* com and cmd */ 63 return (pszExt[1] == 'o' && pszExt[2] == 'm' && pszExt[3] == '\0') 64 || (pszExt[1] == 'm' && pszExt[2] == 'd' && pszExt[3] == '\0'); 65 } 54 66 } 55 67 … … 79 91 return 0; 80 92 81 /* Copy the extension out and lower case it. */93 /* Copy the extension out and lower case it. Fail immediately on non-alpha chars. */ 82 94 for (i = 0; i < cchExt; i++, pszExt++) 83 95 { 84 96 ch = *pszExt; 85 if (ch >= 'A' && ch <= 'Z') 97 if (ch >= 'a' && ch <= 'z') 98 { /* likely */ } 99 else if (ch >= 'A' && ch <= 'Z') 86 100 ch += 'a' - 'A'; 101 else 102 return 0; 87 103 szExt[i] = ch; 88 104 } … … 113 129 return 0; 114 130 115 /* Copy the extension out and lower case it. */131 /* Copy the extension out and lower case it. Fail immediately on non-alpha chars. */ 116 132 pwc = &pwcName[cwcName - cchExt]; 117 133 for (i = 0; i < cchExt; i++, pwc++) 118 134 { 119 135 WCHAR wc = *pwc; 120 if (wc >= 'A' && wc <= 'Z') 136 if (wc >= 'a' && wc <= 'z') 137 { /* likely */ } 138 else if (wc >= 'A' && wc <= 'Z') 121 139 wc += 'a' - 'A'; 122 else if (wc > 255)123 wc = 255;140 else 141 return 0; 124 142 szExt[i] = (char)wc; 125 143 } … … 170 188 fMode |= S_IWOTH | S_IWGRP | S_IWUSR; 171 189 if ( (fAttribs & FILE_ATTRIBUTE_DIRECTORY) 172 || (p szName173 ? birdIsFileExecutable (pszName)174 : birdIsFileExecutable W(pwszName, cbNameW)) )190 || (pwszName 191 ? birdIsFileExecutableW(pwszName, cbNameW) 192 : birdIsFileExecutable(pszName)) ) 175 193 fMode |= S_IXOTH | S_IXGRP | S_IXUSR; 176 194
Note:
See TracChangeset
for help on using the changeset viewer.