VirtualBox

Ignore:
Timestamp:
Jan 28, 2009 9:03:49 PM (16 years ago)
Author:
vboxsync
Message:

gcc warning (strncat may overflow)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp

    r14461 r16337  
    454454        /* Work around silly constant issues - we ought to allow passing
    455455         * constant strings in the hgcm parameters. */
    456         char szName[MAX_NAME_LEN] = "";
    457         char szValue[MAX_VALUE_LEN] = "";
    458         char szFlags[MAX_FLAGS_LEN] = "";
    459         strncat(szName, setProperties[i].pcszName, sizeof(szName));
    460         strncat(szValue, setProperties[i].pcszValue, sizeof(szValue));
    461         strncat(szFlags, setProperties[i].pcszFlags, sizeof(szFlags));
     456        char szName[MAX_NAME_LEN];
     457        char szValue[MAX_VALUE_LEN];
     458        char szFlags[MAX_FLAGS_LEN];
     459        RTStrPrintf(szName, sizeof(szName), "%s", setProperties[i].pcszName);
     460        RTStrPrintf(szValue, sizeof(szValue), "%s", setProperties[i].pcszValue);
     461        RTStrPrintf(szFlags, sizeof(szFlags), "%s", setProperties[i].pcszFlags);
    462462        paParms[0].setPointer (szName, (uint32_t)strlen(szName) + 1);
    463463        paParms[1].setPointer (szValue, (uint32_t)strlen(szValue) + 1);
     
    530530        /* Work around silly constant issues - we ought to allow passing
    531531         * constant strings in the hgcm parameters. */
    532         char szName[MAX_NAME_LEN] = "";
    533         strncat(szName, delProperties[i].pcszName, sizeof(szName));
     532        char szName[MAX_NAME_LEN];
     533        RTStrPrintf(szName, sizeof(szName), "%s", delProperties[i].pcszName);
    534534        paParms[0].setPointer (szName, (uint32_t)strlen(szName) + 1);
    535535        if (delProperties[i].isHost)
     
    608608        AssertBreakStmt(sizeof(szBuffer) >= getProperties[i].cchValue,
    609609                        rc = VERR_INTERNAL_ERROR);
    610         strncat(szName, getProperties[i].pcszName, sizeof(szName));
     610        RTStrPrintf(szName, sizeof(szName), "%s", getProperties[i].pcszName);
    611611        paParms[0].setPointer (szName, (uint32_t)strlen(szName) + 1);
    612612        paParms[1].setPointer (szBuffer, sizeof(szBuffer));
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