VirtualBox

Ignore:
Timestamp:
May 14, 2014 7:38:18 PM (11 years ago)
Author:
vboxsync
Message:

Additions/win/SharedFolders: strip trailing \0 in MAP_FOLDER

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.c

    r51245 r51253  
    176176
    177177        RootNameLength = pNetRoot->pNetRootName->Length - pSrvCall->pSrvCallName->Length;
    178         if (!RootNameLength)
     178        if (RootNameLength < sizeof(WCHAR))
    179179        {
    180180            /* Refuse a netroot path with an empty shared folder name */
     
    187187
    188188        RootNameLength -= sizeof(WCHAR); /* Remove leading backslash. */
    189 
    190189        pRootName = (PWCHAR)(pNetRoot->pNetRootName->Buffer + (pSrvCall->pSrvCallName->Length / sizeof(WCHAR)));
    191190        pRootName++; /* Remove leading backslash. */
    192191
     192        /* Strip the trailing \0. Sometimes there is one, sometimes not... */
     193        if (   RootNameLength >= sizeof(WCHAR)
     194            && pRootName[RootNameLength / sizeof(WCHAR) - 1] == 0)
     195            RootNameLength -= sizeof(WCHAR);
     196
    193197        if (pNetRootExtension->phgcmClient == NULL)
    194198        {
     
    196200                 RootNameLength, RootNameLength / sizeof(WCHAR), pRootName));
    197201
    198             /* Calculate length required for parsed path.
    199              */
    200             ParsedPathSize = sizeof(*ParsedPath) + RootNameLength + sizeof(WCHAR);
    201 
     202            /* Calculate the length required for parsed path. */
     203            ParsedPathSize = sizeof(SHFLSTRING) + RootNameLength + sizeof(WCHAR);
    202204            ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize);
    203205            if (!ParsedPath)
     
    209211
    210212            ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING));
    211 
    212213            ParsedPath->u16Size = (uint16_t)RootNameLength + sizeof(WCHAR);
    213214            ParsedPath->u16Length = ParsedPath->u16Size - sizeof(WCHAR); /* without terminating null */
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