VirtualBox

Changeset 80468 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
Aug 28, 2019 9:57:23 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Made the event source and event IDs more non-deterministic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r80459 r80468  
    2424#include <iprt/semaphore.h>
    2525#include <iprt/path.h>
     26#include <iprt/rand.h>
    2627
    2728#include <iprt/errcore.h>
     
    3536 *
    3637 * @returns VBox status code.
    37  * @param   uID                 Event ID to associate payload to.
     38 * @param   uID                 Payload ID to set for this payload. Useful for consequtive payloads.
    3839 * @param   pvData              Data block to associate to this payload.
    3940 * @param   cbData              Size (in bytes) of data block to associate.
     
    9798 * @returns VBox status code.
    9899 * @param   pEvent              Event to initialize.
    99  * @param   uID                 ID to use for the event.
    100  */
    101 int SharedClipboardEventCreate(PSHAREDCLIPBOARDEVENT pEvent, uint16_t uID)
     100 * @param   uID                 Event ID to use.
     101 */
     102int SharedClipboardEventCreate(PSHAREDCLIPBOARDEVENT pEvent, VBOXCLIPBOARDEVENTID uID)
    102103{
    103104    AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
     
    145146 * @param   uID                 ID to use for event source.
    146147 */
    147 int SharedClipboardEventSourceCreate(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID)
     148int SharedClipboardEventSourceCreate(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTSOURCEID uID)
    148149{
    149150    AssertPtrReturn(pSource, VERR_INVALID_POINTER);
     
    156157
    157158    pSource->uID          = uID;
    158     pSource->uEventIDNext = 1; /* Event ID 0 always is reserved (marks "unused"). */
     159    /* Choose a random event ID starting point. */
     160    pSource->uEventIDNext = RTRandU32() % VBOX_SHARED_CLIPBOARD_MAX_EVENTS;
    159161
    160162    LogFlowFuncLeaveRC(rc);
     
    189191 * @param   pSource             Event source to generate event for.
    190192 */
    191 uint16_t SharedClipboardEventIDGenerate(PSHAREDCLIPBOARDEVENTSOURCE pSource)
     193VBOXCLIPBOARDEVENTID SharedClipboardEventIDGenerate(PSHAREDCLIPBOARDEVENTSOURCE pSource)
    192194{
    193195    AssertPtrReturn(pSource, 0);
    194196
    195197    LogFlowFunc(("uSource=%RU16: New event: %RU16\n", pSource->uID, pSource->uEventIDNext));
    196     return pSource->uEventIDNext++; /** @todo Improve this. */
     198    return pSource->uEventIDNext++; /** @todo Handle rollovers? */
    197199}
    198200
     
    204206 * @param   uID                 Event ID to get.
    205207 */
    206 inline PSHAREDCLIPBOARDEVENT sharedClipboardEventGet(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID)
     208inline PSHAREDCLIPBOARDEVENT sharedClipboardEventGet(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID)
    207209{
    208210    PSHAREDCLIPBOARDEVENT pEvIt;
     
    223225 * @param   uID                 Event ID to register.
    224226 */
    225 int SharedClipboardEventRegister(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID)
     227int SharedClipboardEventRegister(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID)
    226228{
    227229    AssertPtrReturn(pSource, VERR_INVALID_POINTER);
     
    266268 * @param   uID                 Event ID to unregister.
    267269 */
    268 int SharedClipboardEventUnregister(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID)
     270int SharedClipboardEventUnregister(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID)
    269271{
    270272    AssertPtrReturn(pSource, VERR_INVALID_POINTER);
     
    305307 *                              SharedClipboardPayloadFree().
    306308 */
    307 int SharedClipboardEventWait(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID, RTMSINTERVAL uTimeoutMs,
     309int SharedClipboardEventWait(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID, RTMSINTERVAL uTimeoutMs,
    308310                             PSHAREDCLIPBOARDEVENTPAYLOAD* ppPayload)
    309311{
     
    340342 * @param   pPayload            Event payload to associate. Takes ownership. Optional.
    341343 */
    342 int SharedClipboardEventSignal(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID,
     344int SharedClipboardEventSignal(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID,
    343345                               PSHAREDCLIPBOARDEVENTPAYLOAD pPayload)
    344346{
     
    376378 * @param   uID                 Event ID to detach payload for.
    377379 */
    378 void SharedClipboardEventPayloadDetach(PSHAREDCLIPBOARDEVENTSOURCE pSource, uint16_t uID)
     380void SharedClipboardEventPayloadDetach(PSHAREDCLIPBOARDEVENTSOURCE pSource, VBOXCLIPBOARDEVENTID uID)
    379381{
    380382    AssertPtrReturnVoid(pSource);
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