Changeset 108849 in vbox
- Timestamp:
- Apr 4, 2025 11:54:52 AM (6 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168299
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/np/vboxmrxnp.cpp
r106061 r108849 1 1 /* $Id$ */ 2 2 /** @file 3 * VirtualBox Windows Guest Shared Folders - Network provider dll 3 * VirtualBox Windows Guest Shared Folders - Network provider DLL (ring-3). 4 * 5 * Communicates with the ring-0 VBoxSF.sys via IOCtls. 4 6 */ 5 7 … … 484 486 { 485 487 DWORD dwStatus = WN_NOT_CONNECTED; 486 487 488 WCHAR RemoteName[128]; 488 ULONG cbOut = 0; 489 490 Log(("VBOXNP: NPGetConnection: pLocalName = %ls\n", 491 pLocalName)); 489 490 Log(("VBOXNP: NPGetConnection: pLocalName = %ls, *pBufferSize=%d\n", pLocalName, *pBufferSize)); 492 491 493 492 if (pLocalName && pLocalName[0] != 0) … … 495 494 if (pLocalName[1] == L':') 496 495 { 496 ULONG cbOut = 0; 497 497 WCHAR LocalName[3]; 498 498 … … 515 515 dwStatus = WN_NOT_CONNECTED; 516 516 } 517 else 518 { 517 else if (cbOut) 518 { 519 Assert(cbOut % sizeof(WCHAR) == 0); /* Paranoia. */ 519 520 RemoteName[cbOut / sizeof(WCHAR)] = 0; 520 521 if (cbOut == 0) 522 { 523 dwStatus = WN_NO_NETWORK; 524 } 525 } 521 } 522 else /* Buggy VBoxSF.sys code. */ 523 AssertFailedStmt(dwStatus = WN_NO_NETWORK); 526 524 } 527 525 } … … 529 527 if (dwStatus == WN_SUCCESS) 530 528 { 531 ULONG cbRemoteName = (lstrlen(RemoteName) + 1) * sizeof (WCHAR); /* Including the trailing 0. */ 532 533 Log(("VBOXNP: NPGetConnection: RemoteName: %ls, cb %d\n", 529 ULONG const cbRemoteName = ( 1 /* Including the leading '\' */ 530 + lstrlen(RemoteName) 531 + 1 /* Include terminatior */) 532 * sizeof (WCHAR); 533 534 Log(("VBOXNP: NPGetConnection: RemoteName: %ls -> cbRemoteName %d\n", 534 535 RemoteName, cbRemoteName)); 535 536 536 DWORD len = sizeof(WCHAR) + cbRemoteName; /* Including the leading '\'. */ 537 538 if (*pBufferSize >= len) 537 /* Note: *pBufferSize is characters, not bytes! */ 538 if (*pBufferSize * sizeof(WCHAR) >= cbRemoteName) 539 539 { 540 540 pRemoteName[0] = L'\\'; 541 CopyMemory(&pRemoteName[1], RemoteName, cbRemoteName );541 CopyMemory(&pRemoteName[1], RemoteName, cbRemoteName - sizeof(pRemoteName[0]) /* Skip leading '\' */); 542 542 543 543 Log(("VBOXNP: NPGetConnection: returning pRemoteName: %ls\n", … … 549 549 { 550 550 /* Log only real errors. Do not log a 0 bytes try. */ 551 Log(("VBOXNP: NPGetConnection: Buffer overflow: *pBufferSize = %d , len= %d\n",552 *pBufferSize, len));551 Log(("VBOXNP: NPGetConnection: Buffer overflow: *pBufferSize = %d < cbRemoteName = %d\n", 552 *pBufferSize, cbRemoteName)); 553 553 } 554 554 … … 556 556 } 557 557 558 *pBufferSize = len; 559 } 560 561 if ((dwStatus != WN_SUCCESS) && 562 (dwStatus != WN_MORE_DATA)) 563 { 564 Log(("VBOXNP: NPGetConnection: Returned error 0x%08X\n", 565 dwStatus)); 566 } 558 Assert(cbRemoteName % sizeof(WCHAR) == 0); 559 *pBufferSize = cbRemoteName / sizeof(WCHAR); /* Length in characters, not bytes! */ 560 } 561 562 if ( (dwStatus != WN_SUCCESS) 563 && (dwStatus != WN_MORE_DATA)) 564 Log(("VBOXNP: NPGetConnection: Returned error 0x%08X\n", dwStatus)); 567 565 568 566 return dwStatus;
Note:
See TracChangeset
for help on using the changeset viewer.