Index: /trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.c
===================================================================
--- /trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.c	(revision 51252)
+++ /trunk/src/VBox/Additions/WINNT/SharedFolders/driver/net.c	(revision 51253)
@@ -176,5 +176,5 @@
 
         RootNameLength = pNetRoot->pNetRootName->Length - pSrvCall->pSrvCallName->Length;
-        if (!RootNameLength)
+        if (RootNameLength < sizeof(WCHAR))
         {
             /* Refuse a netroot path with an empty shared folder name */
@@ -187,8 +187,12 @@
 
         RootNameLength -= sizeof(WCHAR); /* Remove leading backslash. */
-
         pRootName = (PWCHAR)(pNetRoot->pNetRootName->Buffer + (pSrvCall->pSrvCallName->Length / sizeof(WCHAR)));
         pRootName++; /* Remove leading backslash. */
 
+        /* Strip the trailing \0. Sometimes there is one, sometimes not... */
+        if (   RootNameLength >= sizeof(WCHAR)
+            && pRootName[RootNameLength / sizeof(WCHAR) - 1] == 0)
+            RootNameLength -= sizeof(WCHAR);
+
         if (pNetRootExtension->phgcmClient == NULL)
         {
@@ -196,8 +200,6 @@
                  RootNameLength, RootNameLength / sizeof(WCHAR), pRootName));
 
-            /* Calculate length required for parsed path.
-             */
-            ParsedPathSize = sizeof(*ParsedPath) + RootNameLength + sizeof(WCHAR);
-
+            /* Calculate the length required for parsed path. */
+            ParsedPathSize = sizeof(SHFLSTRING) + RootNameLength + sizeof(WCHAR);
             ParsedPath = (PSHFLSTRING)vbsfAllocNonPagedMem(ParsedPathSize);
             if (!ParsedPath)
@@ -209,5 +211,4 @@
 
             ShflStringInitBuffer(ParsedPath, ParsedPathSize - sizeof(SHFLSTRING));
-
             ParsedPath->u16Size = (uint16_t)RootNameLength + sizeof(WCHAR);
             ParsedPath->u16Length = ParsedPath->u16Size - sizeof(WCHAR); /* without terminating null */
