VirtualBox

Changeset 107377 in vbox


Ignore:
Timestamp:
Dec 19, 2024 9:28:00 AM (4 weeks ago)
Author:
vboxsync
Message:

IPRT/RTFileDelete-r3-nt: Fixed another regression from r162755 which prevented deleting files with specially crafted names on NT4. See comment for details. bugref:10826

File:
1 edited

Legend:

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

    r107346 r107377  
    149149         * grok the reparse point stuff.
    150150         */
    151         else if (rcNt == STATUS_INVALID_PARAMETER)
     151        else if (   rcNt == STATUS_INVALID_PARAMETER)
    152152        {
    153153            fOpenOptions &= ~FILE_OPEN_REPARSE_POINT;
     
    166166                                0 /*EaLength*/);
    167167        }
     168        /*
     169         * When getting STATUS_OBJECT_PATH_NOT_FOUND we re-initialize the object attributes
     170         * with OBJ_CASE_INSENSITIVE and try again. This is necessary for older object managers (i.e. on NT4)
     171         * when trying to delete files with a path *and* leading spaces in the file name,
     172         * i.e. "c:\temp\ file_with_a_leading_space".
     173         *
     174         * See @bugref{10826}.
     175         */
     176        else if (   rcNt == STATUS_OBJECT_PATH_NOT_FOUND)
     177        {
     178            InitializeObjectAttributes(&ObjAttr, &NtName, OBJ_CASE_INSENSITIVE /*fAttrib*/, hRootDir, NULL);
     179
     180            hPath = RTNT_INVALID_HANDLE_VALUE;
     181            RTNT_IO_STATUS_BLOCK_REINIT(&Ios);
     182            rcNt = NtCreateFile(&hPath,
     183                             DELETE | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
     184                             &ObjAttr,
     185                             &Ios,
     186                             NULL /*AllocationSize*/,
     187                             FILE_ATTRIBUTE_NORMAL,
     188                             FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
     189                             FILE_OPEN,
     190                             fOpenOptions,
     191                             NULL /*EaBuffer*/,
     192                             0 /*EaLength*/);
     193        }
     194
    168195        /* else:
    169196           DeleteFileW will retry opening the file w/o FILE_READ_ATTRIBUTES here when
     
    210237            if (!NT_SUCCESS(rcNt) && RT_SUCCESS_NP(rc))
    211238                rc = RTErrConvertFromNtStatus(rcNt);
    212             }
     239        }
    213240        else if (RT_SUCCESS_NP(rc))
    214241            rc = RTErrConvertFromNtStatus(rcNt);
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