VirtualBox

Changeset 13249 in vbox for trunk/src


Ignore:
Timestamp:
Oct 14, 2008 11:30:03 AM (16 years ago)
Author:
vboxsync
Message:

Linux guest clipboard text conversion fix: resulting text length was not calculated (public bugtracket 2015).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/xclient/clipboard.cpp

    r11648 r13249  
    933933    PRTUTF16 pu16GuestText, pu16HostText;
    934934    char *pcGuestText;
    935     unsigned cbHostText, cwHostText, cwGuestText, cbGuestText;
     935    unsigned cbHostText, cwHostText, cwGuestText, cbGuestTextBuffer;
     936    size_t cbGuestTextActual;
    936937    int rc;
    937938
     
    942943    if ((rc != VINF_SUCCESS) || cbHostText == 0)
    943944    {
    944         LogFlow(("vboxClipboardConvertUtf16: vboxClipboardReadHostData returned %Vrc, %d bytes of data\n", rc, cbGuestText));
     945        LogFlow(("vboxClipboardConvertUtf16: vboxClipboardReadHostData returned %Vrc, %d bytes of data\n", rc, cbHostText));
    945946        g_ctx.hostFormats = 0;
    946947        LogFlowFunc(("rc = false\n"));
     
    967968    }
    968969    /* Now convert the Utf16 Linux text to Utf8 */
    969     cbGuestText = cwGuestText * 3;  /* Should always be enough. */
    970     pcGuestText = XtMalloc(cbGuestText);
     970    cbGuestTextBuffer = cwGuestText * 3;  /* Should always be enough. */
     971    pcGuestText = XtMalloc(cbGuestTextBuffer);
    971972    if (pcGuestText == 0)
    972973    {
     
    976977    }
    977978    /* Our runtime can't cope with endian markers. */
    978     rc = RTUtf16ToUtf8Ex(pu16GuestText + 1, cwGuestText - 1, &pcGuestText, cbGuestText, 0);
     979    cbGuestTextActual = 0;
     980    rc = RTUtf16ToUtf8Ex(pu16GuestText + 1, cwGuestText - 1, &pcGuestText, cbGuestTextBuffer, &cbGuestTextActual);
    979981    RTMemFree(reinterpret_cast<char *>(pu16GuestText));
    980982    if (rc != VINF_SUCCESS)
     
    984986        return false;
    985987    }
    986     LogFlow(("vboxClipboardConvertUtf8: converted text is %.*s\n", cbGuestText, pcGuestText));
     988    LogFlow(("vboxClipboardConvertUtf8: converted text is %.*s\n", cbGuestTextActual, pcGuestText));
    987989    *atomTypeReturn = g_ctx.atomUtf8;
    988990    *pValReturn = reinterpret_cast<XtPointer>(pcGuestText);
    989     *pcLenReturn = cbGuestText;
     991    *pcLenReturn = (unsigned long)cbGuestTextActual;
    990992    *piFormatReturn = 8;
    991993    LogFlowFunc(("rc = true\n"));
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