VirtualBox

Changeset 78363 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 1, 2019 6:56:33 PM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Fixed ancient bug in the read code path that used potentially stale file size information to determine EOF and adjust the read, something obviously has not business on the guest side. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.cpp

    r78355 r78363  
    249249#ifdef LOG_ENABLED
    250250    BOOLEAN AsyncIo = BooleanFlagOn(RxContext->Flags, RX_CONTEXT_FLAG_ASYNC_OPERATION);
     251    LONGLONG FileSize;
     252    RxGetFileSizeWithLock((PFCB)capFcb, &FileSize);
    251253#endif
    252     LONGLONG FileSize;
    253 
    254     RxGetFileSizeWithLock((PFCB)capFcb, &FileSize);
    255254
    256255    Log(("VBOXSF: vbsfReadInternal: AsyncIo = %d, Fcb->FileSize = 0x%RX64\n",
     
    261260         ByteCount, ByteOffset, FileSize));
    262261
    263 /** @todo r=bird: This check is incorrect as we must let the host do these
    264  * checks with up-to-date end-of-file data.  What we've got cached here is
    265  * potentially out of date.  (This code is here because someone saw it in some
    266  * sample, I suspect and didn't quite understand what it was all about.  The
    267  * thing is that when FCB_STATE_READCACHING_ENABLED is set, the caller
    268  * already checks and the sample probably wanted to cover its bases.  We,
    269  * don't want to do that as already explained earlier.) */
    270 #ifdef FCB_STATE_READCACHING_ENABLED    /* Correct spelling for Vista 6001 SDK. */
    271     if (!FlagOn(capFcb->FcbState, FCB_STATE_READCACHING_ENABLED))
    272 #else
    273     if (!FlagOn(capFcb->FcbState, FCB_STATE_READCACHEING_ENABLED))
    274 #endif
    275     {
    276         if (ByteOffset >= FileSize)
    277         {
    278             Log(("VBOXSF: vbsfReadInternal: EOF\n"));
    279             return STATUS_END_OF_FILE;
    280         }
    281 
    282         if (ByteCount > FileSize - ByteOffset)
    283             ByteCount = (ULONG)(FileSize - ByteOffset);
    284     }
    285 
    286     /** @todo read 0 bytes == always success? */
    287     if (   !BufferMdl
    288         || ByteCount == 0)
    289     {
    290         AssertFailed();
    291         return STATUS_INVALID_PARAMETER;
    292     }
     262    AssertReturn(BufferMdl, STATUS_INVALID_PARAMETER);
     263    Assert(ByteCount > 0); /* ASSUME this is taken care of elsewhere already. */
    293264
    294265    ctx.pClient = &g_SfClient;
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