VirtualBox

Changeset 97656 in vbox


Ignore:
Timestamp:
Nov 22, 2022 3:20:34 PM (2 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Bail out early from the file copy from/to inner methods if the size to copy is 0 (i.e. empty files).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r97655 r97656  
    398398    RT_NOREF(fFileCopyFlags);
    399399
    400     BOOL fCanceled = FALSE;
     400    if (!cbSize) /* Nothing to copy, i.e. empty file? Bail out. */
     401        return VINF_SUCCESS;
     402
     403    BOOL     fCanceled      = FALSE;
    401404    uint64_t cbWrittenTotal = 0;
    402405    uint64_t cbToRead       = cbSize;
     
    454457            break;
    455458
    456         vrc = setProgress((ULONG)((double)cbWrittenTotal / (double)cbSize / 100.0));
     459        AssertBreakStmt(cbSize, vrc = VERR_INTERNAL_ERROR);
     460        vrc = setProgress(((double)cbWrittenTotal / (double)cbSize) * 100);
    457461        if (RT_FAILURE(vrc))
    458462            break;
     
    470474     * everything.
    471475     */
    472     if (   cbSize > 0
    473         && cbWrittenTotal == 0)
     476    if (cbWrittenTotal == 0)
    474477    {
    475478        /* If nothing was transferred but the file size was > 0 then "vbox_cat" wasn't able to write
     
    728731    RT_NOREF(fFileCopyFlags);
    729732
    730     BOOL fCanceled = FALSE;
     733    if (!cbSize) /* Nothing to copy, i.e. empty file? Bail out. */
     734        return VINF_SUCCESS;
     735
     736    BOOL     fCanceled      = FALSE;
    731737    uint64_t cbWrittenTotal = 0;
    732738    uint64_t cbToRead       = cbSize;
     
    784790            break;
    785791
    786         vrc = setProgress((ULONG)((double)cbWrittenTotal / (double)cbSize / 100.0));
     792        AssertBreakStmt(cbSize, vrc = VERR_INTERNAL_ERROR);
     793        vrc = setProgress(((double)cbWrittenTotal / (double)cbSize) * 100);
    787794        if (RT_FAILURE(vrc))
    788795            break;
     
    796803     * everything.
    797804     */
    798     if (   cbSize > 0
    799         && cbWrittenTotal == 0)
     805    if (cbWrittenTotal == 0)
    800806    {
    801807        /* If nothing was transferred but the file size was > 0 then "vbox_cat" wasn't able to write
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