VirtualBox

Changeset 103443 in vbox for trunk


Ignore:
Timestamp:
Feb 19, 2024 1:53:44 PM (7 months ago)
Author:
vboxsync
Message:

VMM/DBGFR3PlugIn: Less strlen/strcat in dbgfR3PlugInLoadCallback. bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/DBGFR3PlugIn.cpp

    r103285 r103443  
    275275    char        *pszModule = (char *)alloca(cchModule);
    276276    AssertReturn(pszModule, VERR_TRY_AGAIN);
     277
    277278    memcpy(pszModule, pchPath, cchPath);
    278279    pszModule[cchPath] = '\0';
    279280
    280281    int rc = RTPathAppend(pszModule, cchModule, DBGF_PLUG_IN_PREFIX);
    281     AssertRCReturn(rc, VERR_TRY_AGAIN);
    282     rc = RTStrCat(pszModule, cchModule, pPlugIn->szName);
    283     AssertRCReturn(rc, VERR_TRY_AGAIN);
    284     rc = RTStrCat(pszModule, cchModule, pszSuff);
    285     AssertRCReturn(rc, VERR_TRY_AGAIN);
    286     Assert(strlen(pszModule) < cchModule - 4);
     282    AssertRCReturn(rc, VERR_TRY_AGAIN); /* (This cannot possibly fail, just usual paranoia convention.) */
     283    size_t const cchWithPrefix = cchPath + strlen(&pszModule[cchPath]); /* (May have added a slash.) */
     284
     285    Assert(cchWithPrefix + pPlugIn->cchName + cchSuff < cchModule - 4);
     286    memcpy(mempcpy(&pszModule[cchWithPrefix], pPlugIn->szName, pPlugIn->cchName), pszSuff, cchSuff + 1);
    287287
    288288    if (RTPathExists(pszModule))
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