Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-5400

FindFirstFile("foo/invalid/Path", &data) doesn't return ERROR_INVALID_HANDLE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Fix Version/s: 0.4.0
    • Component/s: Win32SS
    • Labels:
      None
    • Environment:

      Operating System: ReactOS
      Platform: x86 Hardware

      Description

      r50888
      Winetest related: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/file.c?revision=50888&view=markup#l_2145

      Here,we are passing to FileFindFirst an inexistant Path to a File.
      It should return ERROR_INVALID_HANDLE and ERROR_PATH_NOT_FOUND

      Checking the calls:
      -FindFirstFileA calls FindFirstFileExA without checking if the Path does exist.
      -FindFirstFileExA calls InternalFindFirstFile, this latter one returns the Handle but until now noone has checked if the Path to the file exists.
      -InternalFindFirstFile implementation:

      00362 bResult = RtlDosPathNameToNtPathName_U (lpFileName,
      00363 &NtPathU,
      00364 (PCWSTR *)((ULONG_PTR)&PathFileName.Buffer),
      00365 &DirInfo);
      00366 if (FALSE == bResult)
      00367

      { 00368 SetLastError(ERROR_PATH_NOT_FOUND); 00369 return INVALID_HANDLE_VALUE; 00370 }

      So seems we are relying in RTLDosPathNameToNtPathName_U to check if the Path exists.
      This could be true in case "lpfilename=NULL", as bresult will be Zero. But if we sent to RTLDosPathNameToNtPathName_U a false path, it will translate, and it will suceed. So bresult will be !0.

      Here we can see the RtlDosPathNameToNtPathName_U behavior:
      http://doxygen.reactos.org/d8/dd5/ndk_2rtlfuncs_8h_a86dd854978cd372fdc21be85ec39c09c.html#a86dd854978cd372fdc21be85ec39c09c
      Some comments:

      • us.Length is greater than 8, so we go into the IF #656.
      • We just return false if buffer is NULL ( line #671)
      • We are not checking inside that IF if we the "lpfilename" exists. Hence bresult!=0 and the Winetest fails.

      Should we sync with WINE these functions?

        Attachments

          Activity

            People

            • Assignee:
              Heis Spiter Pierre Schweitzer
              Reporter:
              vicmarcal vicmarcal
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: