VirtualBox

Changeset 54317 in vbox


Ignore:
Timestamp:
Feb 19, 2015 10:31:33 PM (10 years ago)
Author:
vboxsync
Message:

supdrvCheckInvalidChar -> supdrvIsLdrModuleNameValid and explained its real purpose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r54316 r54317  
    14281428
    14291429/**
    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 */
     1439static bool supdrvIsLdrModuleNameValid(const char *pszName)
    14391440{
    14401441    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;
    14511451}
    14521452
     
    16641664            REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, pReq->u.In.szName[0]);
    16651665            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));
    16671667            REQ_CHECK_EXPR(SUP_IOCTL_LDR_OPEN, RTStrEnd(pReq->u.In.szFilename, sizeof(pReq->u.In.szFilename)));
    16681668
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