VirtualBox

Changeset 23655 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Oct 9, 2009 3:51:35 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53366
Message:

VBoxService: Always use '%s' when passing strings to a formatting function.

Location:
trunk/src/VBox/Additions/common/VBoxService
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceUtils.cpp

    r23634 r23655  
    3737
    3838#ifdef VBOX_WITH_GUEST_PROPS
     39/**
     40 * Wrapper around VbglR3GuestPropWriteValue that does value formatting and
     41 * logging.
     42 *
     43 * @returns VBox status code. Errors will be logged.
     44 *
     45 * @param   u32ClientId     The HGCM client ID for the guest property session.
     46 * @param   pszName         The property name.
     47 * @param   pszValueFormat  The property format string.  If this is NULL then
     48 *                          the property will be removed.
     49 * @param   ...             Format arguments.
     50 */
    3951int VBoxServiceWritePropF(uint32_t u32ClientId, const char *pszName, const char *pszValueFormat, ...)
    4052{
     
    4254    if (pszValueFormat != NULL)
    4355    {
     56        /** @todo Log the value as well? just copy the guts of
     57         *        VbglR3GuestPropWriteValueV. */
    4458        VBoxServiceVerbose(3, "Writing guest property \"%s\"\n", pszName);
    4559        va_list va;
     
    5165    }
    5266    else
     67    {
    5368        rc = VbglR3GuestPropWriteValue(u32ClientId, pszName, NULL);
     69        if (RT_FAILURE(rc))
     70            VBoxServiceError("Error removing guest property \"%s\" (rc=%Rrc)\n", pszName, rc);
     71    }
    5472    return rc;
    5573}
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp

    r23575 r23655  
    380380        {
    381381            VBoxServiceError("Failed to query registry key (install directory)! Error: %Rrc\n", rc);
    382         }   
     382        }
    383383        else
    384384        {
     
    401401
    402402    /* Write information to host. */
    403     rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/InstallDir", szInstDir);
    404     rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Revision", szRev);
    405     rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Version", szVer);
     403    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/InstallDir", "%s", szInstDir);
     404    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Revision", "%s", szRev);
     405    rc = VBoxServiceWritePropF(uiClientID, "/VirtualBox/GuestAdd/Version", "%s", szVer);
    406406
    407407    if (NULL != hKey)
     
    494494        rc = VBoxServiceGetFileVersionString(pTable->pszFilePath, pTable->pszFileName, szVer, sizeof(szVer));
    495495        RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestAdd/Components/%s", pTable->pszFileName);
    496         rc = VBoxServiceWritePropF(uiClientID, szPropPath, szVer);
     496        rc = VBoxServiceWritePropF(uiClientID, szPropPath, "%s", szVer);
    497497        pTable++;
    498498    }
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp

    r23575 r23655  
    159159    char szInfo[256] = {0};
    160160    rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szInfo, sizeof(szInfo));
    161     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product", szInfo);
     161    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Product", "%s", szInfo);
    162162
    163163    rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
    164     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release", szInfo);
     164    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Release", "%s", szInfo);
    165165
    166166    rc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szInfo, sizeof(szInfo));
    167     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version", szInfo);
     167    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/Version", "%s", szInfo);
    168168
    169169    rc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szInfo, sizeof(szInfo));
    170     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack", szInfo);
     170    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/ServicePack", "%s", szInfo);
    171171
    172172    /* Retrieve version information about Guest Additions and installed files (components). */
     
    176176#else
    177177    /* VBoxServiceGetAddsVersion !RT_OS_WINDOWS */
    178     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version", VBOX_VERSION_STRING);
     178    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Version", "%s", VBOX_VERSION_STRING);
    179179
    180180    char szRevision[32];
    181181    RTStrPrintf(szRevision, sizeof(szRevision), "%u", VBOX_SVN_REV);
    182     VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision", szRevision);
     182    VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestAdd/Revision", "%s", szRevision);
    183183#endif
    184184
     
    263263#endif /* !RT_OS_WINDOWS */
    264264
    265         VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", (uiUserCount > 0) ? szUserList : NULL);
     265        if (uiUserCount > 0)
     266            VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", "%s", szUserList);
     267        else
     268            VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsersList", NULL);
    266269        VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/OS/LoggedInUsers", "%u", uiUserCount);
    267270        if (g_VMInfoLoggedInUsers != uiUserCount || g_VMInfoLoggedInUsers == UINT32_MAX)
     
    331334        int iCurIface = 0;
    332335
    333         VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/Net/Count", "%d", (nNumInterfaces > 1 ? nNumInterfaces-1 : 0));
     336        VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, "/VirtualBox/GuestInfo/Net/Count", "%d",
     337                              nNumInterfaces > 1 ? nNumInterfaces-1 : 0);
    334338
    335339        /** @todo Use GetAdaptersInfo() and GetAdapterAddresses (IPv4 + IPv6) for more information. */
     
    369373#endif
    370374            RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Broadcast", iCurIface);
    371             VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, inet_ntoa(pAddress->sin_addr));
     375            VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
    372376
    373377#ifdef RT_OS_WINDOWS
     
    387391#endif
    388392            RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/V4/Netmask", iCurIface);
    389             VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, inet_ntoa(pAddress->sin_addr));
    390 
    391              if (nFlags & IFF_UP)
    392                 RTStrPrintf(szTemp, sizeof(szTemp), "Up");
    393             else
    394                 RTStrPrintf(szTemp, sizeof(szTemp), "Down");
     393            VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, "%s", inet_ntoa(pAddress->sin_addr));
    395394
    396395            RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestInfo/Net/%d/Status", iCurIface);
    397             VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath, szTemp);
     396            VBoxServiceWritePropF(g_VMInfoGuestPropSvcClientID, szPropPath,
     397                                  nFlags & IFF_UP ? "Up" : "Down");
    398398
    399399            iCurIface++;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette