VirtualBox

Changeset 82515 in vbox


Ignore:
Timestamp:
Dec 9, 2019 1:52:29 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135368
Message:

SharedClipboardSvc: Don't let the guest clear the host clipboard unless it's the 'owner'. bugref:9437

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r82513 r82515  
    13351335    /*
    13361336     * Report the formats.
     1337     *
     1338     * We ignore empty reports if the guest isn't the clipboard owner, this
     1339     * prevents a freshly booted guest with an empty clibpoard from clearing
     1340     * the host clipboard on startup.  Likewise, when a guest shutdown it will
     1341     * typically issue an empty report in case it's the owner, we don't want
     1342     * that to clear host content either.
    13371343     */
    1338     int rc = shClSvcSetSource(pClient, SHCLSOURCE_REMOTE);
    1339     if (RT_SUCCESS(rc))
    1340     {
    1341         if (g_ExtState.pfnExtension)
    1342         {
    1343             SHCLEXTPARMS parms;
    1344             RT_ZERO(parms);
    1345             parms.uFormat = fFormats;
    1346 
    1347             g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms));
    1348         }
    1349         else
    1350         {
    1351             SHCLCLIENTCMDCTX CmdCtx;
    1352             RT_ZERO(CmdCtx);
    1353 
    1354             SHCLFORMATDATA FormatData;
    1355             FormatData.fFlags  = 0;
    1356             FormatData.Formats = fFormats;
    1357             rc = ShClSvcImplFormatAnnounce(pClient, &CmdCtx, &FormatData);
    1358         }
    1359 
    1360         /** @todo r=bird: I'm not sure if the guest should be automatically allowed
    1361          *        to write the host clipboard now.  It would make more sense to disallow
    1362          *        host clipboard reads until the host reports formats.
    1363          *
    1364          *        The writes should only really be allowed upon request from the host,
    1365          *        shouldn't they? (Though, I'm not sure, maybe there are situations
    1366          *        where the guest side will just want to push the content over
    1367          *        immediately while it's still available, I don't quite recall now...
    1368          */
     1344    int rc;
     1345    if (!fFormats && pClient->State.enmSource != SHCLSOURCE_REMOTE)
     1346        rc = VINF_SUCCESS;
     1347    else
     1348    {
     1349        rc = shClSvcSetSource(pClient, SHCLSOURCE_REMOTE);
    13691350        if (RT_SUCCESS(rc))
    1370             pClient->State.fFlags |= SHCLCLIENTSTATE_FLAGS_WRITE_ACTIVE;
     1351        {
     1352            if (g_ExtState.pfnExtension)
     1353            {
     1354                SHCLEXTPARMS parms;
     1355                RT_ZERO(parms);
     1356                parms.uFormat = fFormats;
     1357
     1358                g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms));
     1359            }
     1360            else
     1361            {
     1362                SHCLCLIENTCMDCTX CmdCtx;
     1363                RT_ZERO(CmdCtx);
     1364
     1365                SHCLFORMATDATA FormatData;
     1366                FormatData.fFlags  = 0;
     1367                FormatData.Formats = fFormats;
     1368                rc = ShClSvcImplFormatAnnounce(pClient, &CmdCtx, &FormatData);
     1369            }
     1370
     1371            /** @todo r=bird: I'm not sure if the guest should be automatically allowed
     1372             *        to write the host clipboard now.  It would make more sense to disallow
     1373             *        host clipboard reads until the host reports formats.
     1374             *
     1375             *        The writes should only really be allowed upon request from the host,
     1376             *        shouldn't they? (Though, I'm not sure, maybe there are situations
     1377             *        where the guest side will just want to push the content over
     1378             *        immediately while it's still available, I don't quite recall now...
     1379             */
     1380            if (RT_SUCCESS(rc))
     1381                pClient->State.fFlags |= SHCLCLIENTSTATE_FLAGS_WRITE_ACTIVE;
     1382        }
    13711383    }
    13721384
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