VirtualBox

Changeset 84148 in vbox


Ignore:
Timestamp:
May 5, 2020 3:54:35 PM (4 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Made file name allocation of VBOXSERVICECTRLFILE dynamic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r84147 r84148  
    9898    if (RT_SUCCESS(rc))
    9999    {
     100        RTStrFree(pFile->pszName);
     101
    100102        /* Remove file entry in any case. */
    101103        RTListNodeRemove(&pFile->Node);
     
    312314            if (szFile[0])
    313315            {
    314                 RTStrCopy(pFile->szName, sizeof(pFile->szName), szFile);
    315 
     316                pFile->pszName = RTStrDup(szFile);
     317                if (!pFile->pszName)
     318                    rc = VERR_NO_MEMORY;
    316319/** @todo
    317320 * Implement szSharing!
    318321 */
    319322                uint64_t fFlags;
    320                 rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
    321                 VGSvcVerbose(4, "[File %s] Opening with fFlags=%#RX64 -> rc=%Rrc\n", pFile->szName, fFlags, rc);
     323                if (RT_SUCCESS(rc))
     324                {
     325                    rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
     326                    VGSvcVerbose(4, "[File %s] Opening with fFlags=%#RX64 -> rc=%Rrc\n", pFile->pszName, fFlags, rc);
     327                }
     328
    322329                if (RT_SUCCESS(rc))
    323330                {
     
    327334                    if (fFlags & RTFILE_O_READ)
    328335                        fFlags &= ~RTFILE_O_TRUNCATE;
    329                     rc = RTFileOpen(&pFile->hFile, pFile->szName, fFlags);
     336                    rc = RTFileOpen(&pFile->hFile, pFile->pszName, fFlags);
    330337                    if (RT_SUCCESS(rc))
    331338                    {
     
    352359                                    pFile->fOpen   = fFlags;
    353360                                    RTListAppend(&pSession->lstFiles, &pFile->Node);
    354                                     VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle);
     361                                    VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->pszName, pFile->uHandle);
    355362                                }
    356363                                else
    357                                     VGSvcError("[File %s] Seeking to offset %RU64 failed: rc=%Rrc\n", pFile->szName, offOpen, rc);
     364                                    VGSvcError("[File %s] Seeking to offset %RU64 failed: rc=%Rrc\n", pFile->pszName, offOpen, rc);
    358365                            }
    359366                            else
    360367                            {
    361                                 VGSvcError("[File %s] Unsupported mode %#x\n", pFile->szName, objInfo.Attr.fMode);
     368                                VGSvcError("[File %s] Unsupported mode %#x\n", pFile->pszName, objInfo.Attr.fMode);
    362369                                rc = VERR_NOT_SUPPORTED;
    363370                            }
    364371                        }
    365372                        else
    366                             VGSvcError("[File %s] Getting mode failed with rc=%Rrc\n", pFile->szName, rc);
     373                            VGSvcError("[File %s] Getting mode failed with rc=%Rrc\n", pFile->pszName, rc);
    367374                    }
    368375                    else
    369                         VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->szName, rc);
     376                        VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->pszName, rc);
    370377                }
    371378            }
     
    379386            if (RT_FAILURE(rc))
    380387            {
     388                RTStrFree(pFile->pszName);
    381389                if (pFile->hFile != NIL_RTFILE)
    382390                    RTFileClose(pFile->hFile);
     
    425433        if (pFile)
    426434        {
    427             VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->szName : "<Not found>", uHandle);
     435            VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->pszName : "<Not found>", uHandle);
    428436            rc = vgsvcGstCtrlSessionFileFree(pFile);
    429437        }
     
    484492            rc = RTFileRead(pFile->hFile, *ppvScratchBuf, RT_MIN(cbToRead, *pcbScratchBuf), &cbRead);
    485493            offNew = (int64_t)RTFileTell(pFile->hFile);
    486             VGSvcVerbose(5, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc, offNew=%RI64\n", pFile->szName, cbRead, cbToRead, rc, offNew);
     494            VGSvcVerbose(5, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, cbToRead, rc, offNew);
    487495        }
    488496        else
     
    553561            else
    554562                offNew = (int64_t)RTFileTell(pFile->hFile);
    555             VGSvcVerbose(5, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc, offNew=%RI64\n", pFile->szName, cbRead, offReadAt, rc, offNew);
     563            VGSvcVerbose(5, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc, offNew=%RI64\n", pFile->pszName, cbRead, offReadAt, rc, offNew);
    556564        }
    557565        else
     
    613621            offNew = (int64_t)RTFileTell(pFile->hFile);
    614622            VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 =>  %Rrc, cbWritten=%zu, offNew=%RI64\n",
    615                          pFile->szName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), rc, cbWritten, offNew);
     623                         pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), rc, cbWritten, offNew);
    616624        }
    617625        else
     
    685693                offNew = (int64_t)RTFileTell(pFile->hFile);
    686694            VGSvcVerbose(5, "[File %s] Writing %p LB %RU32 @ %RU64 =>  %Rrc, cbWritten=%zu, offNew=%RI64\n",
    687                          pFile->szName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), offWriteAt, rc, cbWritten, offNew);
     695                         pFile->pszName, *ppvScratchBuf, RT_MIN(cbToWrite, *pcbScratchBuf), offWriteAt, rc, cbWritten, offNew);
    688696        }
    689697        else
     
    752760                rc = RTFileSeek(pFile->hFile, (int64_t)offSeek, s_abMethods[uSeekMethod], &offActual);
    753761                VGSvcVerbose(5, "[File %s]: Seeking to offSeek=%RI64, uSeekMethodIPRT=%u, rc=%Rrc\n",
    754                              pFile->szName, offSeek, s_abMethods[uSeekMethod], rc);
     762                             pFile->pszName, offSeek, s_abMethods[uSeekMethod], rc);
    755763            }
    756764            else
     
    806814        {
    807815            offCurrent = RTFileTell(pFile->hFile);
    808             VGSvcVerbose(5, "[File %s]: Telling offCurrent=%RU64\n", pFile->szName, offCurrent);
     816            VGSvcVerbose(5, "[File %s]: Telling offCurrent=%RU64\n", pFile->pszName, offCurrent);
    809817        }
    810818        else
     
    854862        {
    855863            rc = RTFileSetSize(pFile->hFile, cbNew);
    856             VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->szName, cbNew, cbNew, rc);
     864            VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->pszName, cbNew, cbNew, rc);
    857865        }
    858866        else
     
    20452053            if (RT_FAILURE(rc2))
    20462054            {
    2047                 VGSvcError("Unable to close file '%s'; rc=%Rrc\n", pFile->szName, rc2);
     2055                VGSvcError("Unable to close file '%s'; rc=%Rrc\n", pFile->pszName, rc2);
    20482056                if (RT_SUCCESS(rc))
    20492057                    rc = rc2;
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