Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp	(revision 84147)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp	(revision 84148)
@@ -98,4 +98,6 @@
     if (RT_SUCCESS(rc))
     {
+        RTStrFree(pFile->pszName);
+
         /* Remove file entry in any case. */
         RTListNodeRemove(&pFile->Node);
@@ -312,12 +314,17 @@
             if (szFile[0])
             {
-                RTStrCopy(pFile->szName, sizeof(pFile->szName), szFile);
-
+                pFile->pszName = RTStrDup(szFile);
+                if (!pFile->pszName)
+                    rc = VERR_NO_MEMORY;
 /** @todo
  * Implement szSharing!
  */
                 uint64_t fFlags;
-                rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
-                VGSvcVerbose(4, "[File %s] Opening with fFlags=%#RX64 -> rc=%Rrc\n", pFile->szName, fFlags, rc);
+                if (RT_SUCCESS(rc))
+                {
+                    rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
+                    VGSvcVerbose(4, "[File %s] Opening with fFlags=%#RX64 -> rc=%Rrc\n", pFile->pszName, fFlags, rc);
+                }
+
                 if (RT_SUCCESS(rc))
                 {
@@ -327,5 +334,5 @@
                     if (fFlags & RTFILE_O_READ)
                         fFlags &= ~RTFILE_O_TRUNCATE;
-                    rc = RTFileOpen(&pFile->hFile, pFile->szName, fFlags);
+                    rc = RTFileOpen(&pFile->hFile, pFile->pszName, fFlags);
                     if (RT_SUCCESS(rc))
                     {
@@ -352,20 +359,20 @@
                                     pFile->fOpen   = fFlags;
                                     RTListAppend(&pSession->lstFiles, &pFile->Node);
-                                    VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle);
+                                    VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->pszName, pFile->uHandle);
                                 }
                                 else
-                                    VGSvcError("[File %s] Seeking to offset %RU64 failed: rc=%Rrc\n", pFile->szName, offOpen, rc);
+                                    VGSvcError("[File %s] Seeking to offset %RU64 failed: rc=%Rrc\n", pFile->pszName, offOpen, rc);
                             }
                             else
                             {
-                                VGSvcError("[File %s] Unsupported mode %#x\n", pFile->szName, objInfo.Attr.fMode);
+                                VGSvcError("[File %s] Unsupported mode %#x\n", pFile->pszName, objInfo.Attr.fMode);
                                 rc = VERR_NOT_SUPPORTED;
                             }
                         }
                         else
-                            VGSvcError("[File %s] Getting mode failed with rc=%Rrc\n", pFile->szName, rc);
+                            VGSvcError("[File %s] Getting mode failed with rc=%Rrc\n", pFile->pszName, rc);
                     }
                     else
-                        VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->szName, rc);
+                        VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->pszName, rc);
                 }
             }
@@ -379,4 +386,5 @@
             if (RT_FAILURE(rc))
             {
+                RTStrFree(pFile->pszName);
                 if (pFile->hFile != NIL_RTFILE)
                     RTFileClose(pFile->hFile);
@@ -425,5 +433,5 @@
         if (pFile)
         {
-            VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->szName : "<Not found>", uHandle);
+            VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->pszName : "<Not found>", uHandle);
             rc = vgsvcGstCtrlSessionFileFree(pFile);
         }
@@ -484,5 +492,5 @@
             rc = RTFileRead(pFile->hFile, *ppvScratchBuf, RT_MIN(cbToRead, *pcbScratchBuf), &cbRead);
             offNew = (int64_t)RTFileTell(pFile->hFile);
-            VGSvcVerbose(5, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc, offNew=%RI64\n", pFile->szName, cbRead, cbToRead, rc, offNew);
+            VGSvcVerbose(5, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, cbToRead, rc, offNew);
         }
         else
@@ -553,5 +561,5 @@
             else
                 offNew = (int64_t)RTFileTell(pFile->hFile);
-            VGSvcVerbose(5, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc, offNew=%RI64\n", pFile->szName, cbRead, offReadAt, rc, offNew);
+            VGSvcVerbose(5, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, offReadAt, rc, offNew);
         }
         else
@@ -613,5 +621,5 @@
             offNew = (int64_t)RTFileTell(pFile->hFile);
             VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 =>  %Rrc, cbWritten=%zu, offNew=%RI64\n",
-                         pFile->szName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), rc, cbWritten, offNew);
+                         pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), rc, cbWritten, offNew);
         }
         else
@@ -685,5 +693,5 @@
                 offNew = (int64_t)RTFileTell(pFile->hFile);
             VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 @ %RU64 =>  %Rrc, cbWritten=%zu, offNew=%RI64\n",
-                         pFile->szName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), offWriteAt, rc, cbWritten, offNew);
+                         pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), offWriteAt, rc, cbWritten, offNew);
         }
         else
@@ -752,5 +760,5 @@
                 rc = RTFileSeek(pFile->hFile, (int64_t)offSeek, s_abMethods[uSeekMethod], &offActual);
                 VGSvcVerbose(5, "[File %s]: Seeking to offSeek=%RI64, uSeekMethodIPRT=%u, rc=%Rrc\n",
-                             pFile->szName, offSeek, s_abMethods[uSeekMethod], rc);
+                             pFile->pszName, offSeek, s_abMethods[uSeekMethod], rc);
             }
             else
@@ -806,5 +814,5 @@
         {
             offCurrent = RTFileTell(pFile->hFile);
-            VGSvcVerbose(5, "[File %s]: Telling offCurrent=%RU64\n", pFile->szName, offCurrent);
+            VGSvcVerbose(5, "[File %s]: Telling offCurrent=%RU64\n", pFile->pszName, offCurrent);
         }
         else
@@ -854,5 +862,5 @@
         {
             rc = RTFileSetSize(pFile->hFile, cbNew);
-            VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->szName, cbNew, cbNew, rc);
+            VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->pszName, cbNew, cbNew, rc);
         }
         else
@@ -2045,5 +2053,5 @@
             if (RT_FAILURE(rc2))
             {
-                VGSvcError("Unable to close file '%s'; rc=%Rrc\n", pFile->szName, rc2);
+                VGSvcError("Unable to close file '%s'; rc=%Rrc\n", pFile->pszName, rc2);
                 if (RT_SUCCESS(rc))
                     rc = rc2;
