Changeset 75405 in vbox
- Timestamp:
- Nov 12, 2018 7:43:51 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126547
- Location:
- trunk/src/VBox/Additions/os2/VBoxSF
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSF.cpp
r75337 r75405 359 359 * @returns VBox status code. 360 360 * @param pName The name of the folder to map. 361 * @param pszTag Folder tag (for the VBoxService automounter). Optional. 361 362 * @param ppFolder Where to return the folder structure on success. 362 363 * 363 364 * @remarks Caller owns g_MtxFolder exclusively! 364 365 */ 365 static int vboxSfOs2MapFolder(PSHFLSTRING pName, PVBOXSFFOLDER *ppFolder)366 static int vboxSfOs2MapFolder(PSHFLSTRING pName, const char *pszTag, PVBOXSFFOLDER *ppFolder) 366 367 { 367 368 int rc; 368 PVBOXSFFOLDER pNew = (PVBOXSFFOLDER)RTMemAlloc(RT_UOFFSETOF_DYN(VBOXSFFOLDER, szName[pName->u16Length + 1])); 369 size_t const cbTag = pszTag ? strlen(pszTag) + 1 : NULL; 370 PVBOXSFFOLDER pNew = (PVBOXSFFOLDER)RTMemAlloc(RT_UOFFSETOF_DYN(VBOXSFFOLDER, szName[pName->u16Length + 1 + cbTag])); 369 371 if (pNew != NULL) 370 372 { … … 375 377 RT_ZERO(pNew->hHostFolder); 376 378 pNew->hVpb = 0; 379 pNew->cbNameAndTag = pName->u16Length + (uint16_t)cbTag; 380 pNew->cchName = (uint8_t)pName->u16Length; 377 381 pNew->cchName = (uint8_t)pName->u16Length; 378 382 memcpy(pNew->szName, pName->String.utf8, pName->u16Length); 379 383 pNew->szName[pName->u16Length] = '\0'; 384 if (cbTag) 385 memcpy(&pNew->szName[pName->u16Length + 1], pszTag, cbTag); 380 386 381 387 rc = VbglR0SfMapFolder(&g_SfClient, pName, &pNew->hHostFolder); … … 552 558 * Do the attaching. 553 559 */ 554 rc = vboxSfOs2MapFolder(pStrName, ppFolder);560 rc = vboxSfOs2MapFolder(pStrName, NULL, ppFolder); 555 561 vboxSfOs2StrFree(pStrName); 556 562 if (RT_SUCCESS(rc)) … … 764 770 } 765 771 766 /* Make sure it's only ascii and contains not weird stuff. */ 767 unsigned off = pStrName->u16Length; 772 /* Make sure it's only ascii and contains not weird stuff. 773 Note! There could be a 2nd tag string, so identify that one. */ 774 const char *pszTag = NULL; 775 unsigned off = pStrName->u16Length; 768 776 while (off-- > 0) 769 777 { … … 771 779 if (ch < 0x20 || ch >= 0x7f || ch == ':' || ch == '\\' || ch == '/') 772 780 { 773 LogRel(("vboxSfOs2Attach: Malformed folder name: %.*Rhxs (off %#x)\n", pStrName->u16Length, pStrName->String.utf8, off)); 774 return ERROR_INVALID_PARAMETER; 775 } 776 } 781 if (ch == '\0' && !pszTag && off + 1 < pStrName->u16Length && off > 0) 782 { 783 pszTag = &pStrName->String.ach[off + 1]; 784 pStrName->u16Length = (uint16_t)off; 785 } 786 else 787 { 788 LogRel(("vboxSfOs2Attach: Malformed folder name: %.*Rhxs (off %#x)\n", pStrName->u16Length, pStrName->String.utf8, off)); 789 return ERROR_INVALID_PARAMETER; 790 } 791 } 792 } 793 794 /* Is there a tag following the name? */ 777 795 778 796 if (!pVpFsd) … … 794 812 rc = vboxSfOs2EnsureConnected(); 795 813 if (RT_SUCCESS(rc)) 796 rc = vboxSfOs2MapFolder(pStrName, &pFolder);814 rc = vboxSfOs2MapFolder(pStrName, pszTag, &pFolder); 797 815 } 798 816 if (pFolder && RT_SUCCESS(rc)) … … 919 937 920 938 /* Try copy out the data. */ 921 if (cbParam >= sizeof(USHORT) + pFolder->c chName + 1)922 { 923 *pcbParam = (uint16_t)sizeof(USHORT) + pFolder->c chName + 1;939 if (cbParam >= sizeof(USHORT) + pFolder->cbNameAndTag) 940 { 941 *pcbParam = (uint16_t)sizeof(USHORT) + pFolder->cbNameAndTag; 924 942 cbParam = pFolder->cchName + 1; 925 943 rc = KernCopyOut(pbData, &cbParam, sizeof(cbParam)); 926 944 if (rc != NO_ERROR) 927 rc = KernCopyOut(pbData + sizeof(USHORT), pFolder->szName, pFolder->c chName + 1);945 rc = KernCopyOut(pbData + sizeof(USHORT), pFolder->szName, pFolder->cbNameAndTag); 928 946 } 929 947 else -
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInternal.h
r75337 r75405 78 78 USHORT hVpb; 79 79 80 /** The length of the name and tag, including zero terminators and such. */ 81 uint16_t cbNameAndTag; 80 82 /** The length of the folder name. */ 81 83 uint8_t cchName; 82 /** The shared folder name. */84 /** The shared folder name. If there is a tag it follows as a second string. */ 83 85 char szName[RT_FLEXIBLE_ARRAY]; 84 86 } VBOXSFFOLDER;
Note:
See TracChangeset
for help on using the changeset viewer.