VirtualBox

Changeset 70419 in vbox


Ignore:
Timestamp:
Jan 2, 2018 11:17:06 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120024
Message:

iprt/direnum-r3-nt.cpp: Workaround for buggy fat driver on NT 3.1 (and possibly later). Fixed assertion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp

    r69753 r70419  
    4343#include "internal/dir.h"
    4444#include "internal/path.h"
     45#include "../win/internal-r3-win.h"
    4546
    4647
     
    200201static int rtDirNtCheckRecord(PRTDIRINTERNAL pThis)
    201202{
    202 #ifdef RTDIR_NT_STRICT
     203#if defined(RTDIR_NT_STRICT) || defined(RT_ARCH_X86)
    203204# ifdef IPRT_WITH_NT_PATH_PASSTHRU
    204205    if (pThis->enmInfoClass != FileMaximumInformation)
     
    210211        else
    211212            uEndAddr = (uintptr_t)&pThis->uCurData.pBoth->FileName[0];
     213
     214# ifdef RT_ARCH_X86
     215        /* Workaround for NT 3.1 bug where FAT returns a too short buffer length.
     216           Including all NT 3.x versions in case it bug was fixed till NT 4. */
     217        uintptr_t const uEndBuffer = (uintptr_t)&pThis->pabBuffer[pThis->cbBuffer];
     218        if (   uEndAddr < uEndBuffer
     219            && uEndAddr + pThis->uCurData.pBoth->FileNameLength <= uEndBuffer)
     220        { /* likely */ }
     221        else if (   (   g_enmWinVer == kRTWinOSType_NT310
     222                     || g_enmWinVer == kRTWinOSType_NT350 // not sure when it was fixed...
     223                     || g_enmWinVer == kRTWinOSType_NT351)
     224                 && pThis->enmInfoClass == FileBothDirectoryInformation)
     225        {
     226            size_t cbLeft = (uintptr_t)&pThis->pabBuffer[pThis->cbBufferAlloc] - (uintptr_t)pThis->uCurData.pBoth;
     227            if (   cbLeft >= RT_UOFFSETOF(FILE_BOTH_DIR_INFORMATION, FileName)
     228                && pThis->uCurData.pBoth->FileNameLength > 0
     229                && cbLeft >= RT_UOFFSETOF(FILE_BOTH_DIR_INFORMATION, FileName) + pThis->uCurData.pBoth->FileNameLength)
     230            {
     231                pThis->cbBuffer = ((uintptr_t)&pThis->uCurData.pBoth->FileName[0] + pThis->uCurData.pBoth->FileNameLength)
     232                                - (uintptr_t)&pThis->pabBuffer[0];
     233            }
     234        }
     235# endif
     236
     237# ifdef RTDIR_NT_STRICT
    212238        AssertReturn(uEndAddr < (uintptr_t)&pThis->pabBuffer[pThis->cbBuffer], VERR_IO_GEN_FAILURE);
    213 
    214239        AssertReturn(pThis->uCurData.pBoth->FileNameLength < _64K, VERR_FILENAME_TOO_LONG);
    215240        AssertReturn((pThis->uCurData.pBoth->FileNameLength & 1) == 0, VERR_IO_GEN_FAILURE);
     
    220245        AssertReturn((unsigned)pThis->uCurData.pBoth->ShortNameLength <= sizeof(pThis->uCurData.pBoth->ShortName),
    221246                     VERR_IO_GEN_FAILURE);
     247# endif
    222248    }
    223249#else
     
    472498        return RTErrConvertFromNtStatus(rcNt);
    473499    }
    474     Assert(Ios.Information > sizeof(*pThis->uCurData.pBoth));
     500    AssertMsg(  Ios.Information
     501              > (pThis->enmInfoClass == FileMaximumInformation ? sizeof(*pThis->uCurData.pObjDir) : sizeof(*pThis->uCurData.pBoth)),
     502              ("Ios.Information=%#x\n", Ios.Information));
    475503
    476504    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette