VirtualBox

Changeset 103618 in vbox


Ignore:
Timestamp:
Feb 29, 2024 7:07:40 PM (7 months ago)
Author:
vboxsync
Message:

Shared Clipboard/Transfers: Some more validation in ShClTransferRootsInitFromStringListEx(). bugref:9437

File:
1 edited

Legend:

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

    r103616 r103618  
    18541854    PSHCLLIST pLstRoots      = &pTransfer->lstRoots;
    18551855    char     *pszPathRootAbs = NULL;
     1856    size_t    cchPathRootAbs = 0;
    18561857
    18571858    RTCList<RTCString> lstRootEntries = RTCString(pszRoots, cbRoots).split(pszSep);
     
    19021903                if (RTPathStartsWithRoot(pszPathRootAbs))
    19031904                {
    1904                     rc = ShClTransferValidatePath(pszPathRootAbs, true /* Path must exist */);
     1905                    cchPathRootAbs = RTStrNLen(pszPathRootAbs, RTPATH_MAX);
     1906                    LogRel2(("Shared Clipboard: Transfer uses root '%s'\n", pszPathRootAbs));
    19051907                }
    19061908                else
     
    19251927                    {
    19261928                        /* Calculate the relative path within the root path. */
    1927                         const char *pszPathRelToRoot = &pszPathCur[strlen(pszPathRootAbs) + 1 /* Skip terminator or (back)slash. */];
     1929                        Assert(RTStrNLen(pszPathCur, RTPATH_MAX) >= cchPathRootAbs); /* Sanity. */
     1930                        const char *pszPathRelToRoot = pszPathCur + cchPathRootAbs;
    19281931                        if (    pszPathRelToRoot
    19291932                            && *pszPathRelToRoot != '\0')
    19301933                        {
    1931                             LogFlowFunc(("pszPathRelToRoot=%s\n", pszPathRelToRoot));
     1934                            LogRel2(("Shared Clipboard: Adding list entry '%s'\n", pszPathRelToRoot));
    19321935
    19331936                            rc = ShClTransferListEntryInitEx(pEntry, VBOX_SHCL_INFO_F_FSOBJINFO, pszPathRelToRoot,
     
    19371940                                rc = ShClTransferListAddEntry(pLstRoots, pEntry, true /* fAppend */);
    19381941                                if (RT_SUCCESS(rc))
    1939                                 {
    19401942                                    pFsObjInfo = NULL; /* pEntry has ownership now. */
    1941                                 }
    19421943                            }
    19431944                        }
    19441945                        else
     1946                        {
    19451947                            LogRel(("Shared Clipboard: Unable to construct relative path for '%s' (root is '%s')\n",
    19461948                                    pszPathCur, pszPathRootAbs));
     1949                            rc = VERR_PATH_DOES_NOT_START_WITH_ROOT;
     1950                        }
    19471951                    }
    19481952
     
    19651969
    19661970    /* No (valid) root directory found? Bail out early. */
    1967     if (!pszPathRootAbs)
     1971    if (   RT_SUCCESS(rc)
     1972        && !pszPathRootAbs)
    19681973        rc = VERR_PATH_DOES_NOT_START_WITH_ROOT;
    19691974
     
    19721977        pTransfer->pszPathRootAbs = pszPathRootAbs;
    19731978        LogFlowFunc(("pszPathRootAbs=%s, cRoots=%zu\n", pTransfer->pszPathRootAbs, pTransfer->lstRoots.Hdr.cEntries));
    1974 
    1975         LogRel2(("Shared Clipboard: Transfer uses root '%s'\n", pTransfer->pszPathRootAbs));
    19761979    }
    19771980    else
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