VirtualBox

Changeset 95865 in vbox


Ignore:
Timestamp:
Jul 27, 2022 1:18:54 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152590
Message:

VBoxTray/VBoxClipboard: Drop strsafe.h as it requires stdio.h which we don't have in VBOX_WITH_NOCRT_STATIC mode. Replacing StringCbLengthW with RTUtf16NLenEx. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r93396 r95865  
    2828#include <iprt/asm.h>
    2929#include <iprt/errcore.h>
     30#include <iprt/ldr.h>
    3031#include <iprt/mem.h>
    31 #include <iprt/ldr.h>
    32 
     32#include <iprt/utf16.h>
    3333
    3434#include <VBox/GuestHost/SharedClipboard.h>
     
    3939# include <VBox/GuestHost/SharedClipboard-transfers.h>
    4040#endif
    41 
    42 #include <strsafe.h>
    4341
    4442#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     
    418416                                if (fFormat == VBOX_SHCL_FMT_UNICODETEXT)
    419417                                {
    420                                     size_t cbActual = 0;
    421                                     HRESULT hrc = StringCbLengthW((LPWSTR)pvMem, cb, &cbActual);
    422                                     if (FAILED(hrc))
     418                                    size_t cwcActual = 0;
     419                                    rc = RTUtf16NLenEx((PCRTUTF16)pvMem, cb / sizeof(RTUTF16), &cwcActual);
     420                                    if (RT_SUCCESS(rc))
     421                                        cb = (uint32_t)((cwcActual + 1 /* '\0' */) * sizeof(RTUTF16));
     422                                    else
    423423                                    {
    424                                         LogRel(("Shared Clipboard: Received host data is invalid (%RU32 vs. %zu)\n",
    425                                                 cb, cbActual));
     424                                        LogRel(("Shared Clipboard: Invalid UTF16 string from host: cb=%RU32, cwcActual=%zu, rc=%Rrc\n",
     425                                                cb, cwcActual, rc));
    426426
    427427                                        /* Discard invalid data. */
     
    429429                                        GlobalFree(hMem);
    430430                                        hMem = NULL;
    431                                     }
    432                                     else
    433                                     {
    434                                         /* cbActual is the number of bytes, excluding those used
    435                                          * for the terminating null character.
    436                                          */
    437                                         cb = (uint32_t)(cbActual + 2);
    438431                                    }
    439432                                }
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