VirtualBox

Ignore:
Timestamp:
Dec 12, 2017 5:36:51 PM (7 years ago)
Author:
vboxsync
Message:

Guest properties: Added a length check for GuestPropWriteFlags() and got rid of strcpy(), as this now also is marked as being deprecated on macOS.

Location:
trunk/src/VBox/HostServices/GuestProperties
Files:
2 edited

Legend:

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

    r70063 r70086  
    619619    {
    620620        char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    621         rc = GuestPropWriteFlags(pProp->mFlags, szFlags);
     621        rc = GuestPropWriteFlags(pProp->mFlags, szFlags, sizeof(szFlags));
    622622        if (RT_SUCCESS(rc))
    623623        {
     
    857857
    858858    char            szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    859     int rc = GuestPropWriteFlags(pProp->mFlags, szFlags);
     859    int rc = GuestPropWriteFlags(pProp->mFlags, szFlags, sizeof(szFlags));
    860860    if (RT_FAILURE(rc))
    861861        return rc;
     
    10161016    {
    10171017        char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    1018         rc = GuestPropWriteFlags(prop.mFlags, szFlags);
     1018        rc = GuestPropWriteFlags(prop.mFlags, szFlags, sizeof(szFlags));
    10191019        if (RT_SUCCESS(rc))
    10201020        {
     
    12151215            /* Send out a host notification */
    12161216            const char *pszValue = prop.mValue.c_str();
    1217             rc = GuestPropWriteFlags(prop.mFlags, szFlags);
     1217            rc = GuestPropWriteFlags(prop.mFlags, szFlags, sizeof(szFlags));
    12181218            if (RT_SUCCESS(rc))
    12191219                rc = notifyHost(pszProperty, pszValue, u64Timestamp, szFlags);
     
    14061406
    14071407    char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    1408     int rc = GuestPropWriteFlags(pProp->mFlags, szFlags);
     1408    int rc = GuestPropWriteFlags(pProp->mFlags, szFlags, sizeof(szFlags));
    14091409    if (RT_FAILURE(rc))
    14101410        RTStrPrintf(szFlags, sizeof(szFlags), "???");
  • trunk/src/VBox/HostServices/GuestProperties/testcase/tstGuestPropSvc.cpp

    r70063 r70086  
    120120        if (RT_SUCCESS(rc))
    121121        {
    122             rc = GuestPropWriteFlags(fFlags, pszFlagBuffer);
     122            rc = GuestPropWriteFlags(fFlags, pszFlagBuffer, GUEST_PROP_MAX_FLAGS_LEN);
    123123            if (RT_FAILURE(rc))
    124124                RTTestIFailed("Failed to convert flag string '%s' back to a string.",
     
    159159        RTTestISub("Rejection of an invalid flags field");
    160160        /* This is required to fail. */
    161         if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer)))
     161        if (RT_SUCCESS(GuestPropWriteFlags(u32BadFlags, pszFlagBuffer, GUEST_PROP_MAX_FLAGS_LEN)))
    162162        {
    163163            RTTestIFailed("Flags 0x%x were incorrectly written out as '%.*s'\n",
     
    828828    {
    829829        char szFlags[GUEST_PROP_MAX_FLAGS_LEN];
    830         if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags)))
     830        if (RT_FAILURE(GuestPropWriteFlags(fFlags, szFlags, sizeof(szFlags))))
    831831            RTTestIFailed("Failed to set the global flags.");
    832832        else
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