VirtualBox

Changeset 85567 in vbox


Ignore:
Timestamp:
Jul 30, 2020 5:21:27 PM (5 years ago)
Author:
vboxsync
Message:

GA/Linux: bugref:9804: Trunk GAs have a VBoxClient shared clipboard assertion crash problem on Linux 3.10 kernels

Location:
trunk/src/VBox/GuestHost/SharedClipboard
Files:
2 edited

Legend:

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

    r84717 r85567  
    129129    /** @todo Add Wayland / Weston support. */
    130130#endif
    131     /** @todo r=aeichner The "LAST" in there was causing tstClipboardGH-X11.cpp:XInternAtom to crash because it was reading out side of the array. */
    132     { NULL,                                 SHCLX11FMT_INVALID,     VBOX_SHCL_FMT_NONE },
    133131};
    134132
     
    185183
    186184
     185#ifdef TESTCASE
     186/**
     187 * Return the max. number of elements in the X11 format table.
     188 * Used by the testing code in tstClipboardGH-X11.cpp
     189 * which cannot use RT_ELEMENTS(g_aFormats) directly.
     190 *
     191 * @return size_t The number of elements in the g_aFormats array.
     192 */
     193SHCL_X11_DECL(size_t) clipReportMaxX11Formats(void)
     194{
     195    return (RT_ELEMENTS(g_aFormats));
     196}
     197#endif
     198
    187199/**
    188200 * Returns the atom corresponding to a supported X11 format.
     
    195207{
    196208    LogFlowFunc(("format=%u -> pcszAtom=%s\n", uFmtIdx, g_aFormats[uFmtIdx].pcszAtom));
    197     AssertReturn(uFmtIdx <= RT_ELEMENTS(g_aFormats), 0);
     209    AssertReturn(uFmtIdx < RT_ELEMENTS(g_aFormats), 0);
    198210    return clipGetAtom(pCtx, g_aFormats[uFmtIdx].pcszAtom);
    199211}
     
    207219SHCL_X11_DECL(SHCLX11FMT) clipRealFormatForX11Format(SHCLX11FMTIDX uFmtIdx)
    208220{
    209     AssertReturn(uFmtIdx <= RT_ELEMENTS(g_aFormats), SHCLX11FMT_INVALID);
     221    AssertReturn(uFmtIdx < RT_ELEMENTS(g_aFormats), SHCLX11FMT_INVALID);
    210222    return g_aFormats[uFmtIdx].enmFmtX11;
    211223}
     
    219231static SHCLFORMAT clipVBoxFormatForX11Format(SHCLX11FMTIDX uFmtIdx)
    220232{
    221     AssertReturn(uFmtIdx <= RT_ELEMENTS(g_aFormats), VBOX_SHCL_FMT_NONE);
     233    AssertReturn(uFmtIdx < RT_ELEMENTS(g_aFormats), VBOX_SHCL_FMT_NONE);
    222234    return g_aFormats[uFmtIdx].uFmtVBox;
    223235}
     
    729741        for (i = 0; i < *pcLen; ++i)
    730742        {
    731             for (j = 0; j < RT_ELEMENTS(g_aFormats) - 1; ++j) /** @todo r=aeichner Don't include the last invalid format. */
     743            for (j = 0; j < RT_ELEMENTS(g_aFormats); ++j)
    732744            {
    733745                Atom target = XInternAtom(XtDisplay(widget),
     
    23462358    return rc;
    23472359}
    2348 
  • trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp

    r82922 r85567  
    4141extern SHCLX11FMT clipRealFormatForX11Format(SHCLX11FMTIDX uFmtIdx);
    4242extern Atom clipGetAtom(PSHCLX11CTX pCtx, const char *pcszName);
     43extern size_t clipReportMaxX11Formats(void);
    4344
    4445
     
    187188    Atom atom = 0;
    188189    unsigned i = 0;
    189     while (g_aFormats[i].pcszAtom)
     190    const size_t j = clipReportMaxX11Formats();
     191
     192    for (i = 0; i < j; ++i)
    190193    {
    191194        if (!strcmp(pcsz, g_aFormats[i].pcszAtom))
    192195            atom = (Atom) (i + 0x1000);
    193         ++i;
    194196    }
    195197    for (i = 0; i < RT_ELEMENTS(g_tst_apszSupAtoms); ++i)
     
    366368    {
    367369        unsigned index = atom - 0x1000;
     370        AssertReturn(index < clipReportMaxX11Formats(), NULL);
    368371        pcszName = g_aFormats[index].pcszAtom;
    369372    }
     
    420423static SHCLX11FMTIDX tstClipFindX11FormatByAtomText(const char *pcszAtom)
    421424{
    422     unsigned i = 0;
    423     while (g_aFormats[i].pcszAtom)
     425    const size_t j = clipReportMaxX11Formats();
     426
     427    for (unsigned i = 0; i < j; ++i)
    424428    {
    425429        if (!strcmp(g_aFormats[i].pcszAtom, pcszAtom))
    426430            return i;
    427         ++i;
    428431    }
    429432    return NIL_CLIPX11FORMAT;
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