Changeset 54317 in vbox for trunk/src/VBox/HostDrivers/Support/SUPDrv.c
- Timestamp:
- Feb 19, 2015 10:31:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r54316 r54317 1428 1428 1429 1429 /** 1430 * Helper for supdrvIOCtl. Check if pszStr contains any character of pszChars. 1431 * We would use strpbrk here if this function would be contained in the RedHat kABI white 1432 * list, see http://www.kerneldrivers.org/RHEL5. 1433 * 1434 * @returns 1 if pszStr does contain any character of pszChars, 0 otherwise. 1435 * @param pszStr String to check 1436 * @param pszChars Character set 1437 */ 1438 static int supdrvCheckInvalidChar(const char *pszStr, const char *pszChars) 1430 * Helper for supdrvIOCtl used to validate module names passed to SUP_IOCTL_LDR_OPEN. 1431 * 1432 * Check if pszStr contains any character of pszChars. We would use strpbrk 1433 * here if this function would be contained in the RedHat kABI white list, see 1434 * http://www.kerneldrivers.org/RHEL5. 1435 * 1436 * @returns true if fine, false if not. 1437 * @param pszName The module name to check. 1438 */ 1439 static bool supdrvIsLdrModuleNameValid(const char *pszName) 1439 1440 { 1440 1441 int chCur; 1441 while ((chCur = *pszStr++) != '\0') 1442 { 1443 int ch; 1444 const char *psz = pszChars; 1445 while ((ch = *psz++) != '\0') 1446 if (ch == chCur) 1447 return 1; 1448 1449 } 1450 return 0; 1442 while ((chCur = *pszName++) != '\0') 1443 { 1444 static const char s_szInvalidChars[] = ";:()[]{}/\\|&*%#@!~`\"'"; 1445 unsigned offInv = RT_ELEMENTS(s_szInvalidChars); 1446 while (offInv-- > 0) 1447 if (s_szInvalidChars[offInv] == chCur) 1448 return false; 1449 } 1450 return true; 1451 1451 } 1452 1452 … … 1664 1664 REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, pReq->u.In.szName[0]); 1665 1665 REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, RTStrEnd(pReq->u.In.szName, sizeof(pReq->u.In.szName))); 1666 REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, !supdrvCheckInvalidChar(pReq->u.In.szName, ";:()[]{}/\\|&*%#@!~`\"'"));1666 REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, supdrvIsLdrModuleNameValid(pReq->u.In.szName)); 1667 1667 REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, RTStrEnd(pReq->u.In.szFilename, sizeof(pReq->u.In.szFilename))); 1668 1668
Note:
See TracChangeset
for help on using the changeset viewer.