Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When FindFilesWithPattern fails with STATUS_NOT_IMPLEMENTED, DispatchDirectoryInformation returns the first entry from FindFiles #1149

Closed
5 tasks done
inetic opened this issue May 11, 2023 · 6 comments

Comments

@inetic
Copy link

inetic commented May 11, 2023

Environment

  • Windows version: 10
  • Processor architecture: Core i5 3210M
  • Dokany version: 5464da7 - the one currently used by dokan-rust.
  • Library type (Dokany/FUSE): Found this issue while using dokan-rust, but it's likely a problem in Dokany

Check List

  • I checked my issue doesn't exist yet
  • My issue is valid with mirror default sample and not specific to my user-mode driver implementation
  • I can always reproduce the issue with the provided description below.
  • I have updated Dokany to the latest version and have reboot my computer after.
  • I tested one of the last snapshot from appveyor CI

Description

When the FindFilesWithPattern is set to non-NULL but fails with STATUS_NOT_IMPLEMENTED, the code in DispatchDirectoryInformation will go on to use FindFiles here.

If IoEvent->EventContext->Operation.Directory.SearchPatternLength is set, then the assumption is that the output from FindFiles shall be filtered in MatchFiles (going from DispatchDirectoryInformation > EndFindFilesCommon > WriteDirectoryResults > MatchFiles).

Now in MatchFiles, because FindFilesWithPattern is non-NULL, the variable patternCheck is not set to TRUE here. That means that this if condition always succeeds and the function returns whatever was the first entry returned by FindFiles (as opposed to the first entry that matches the pattern.

I first encountered the issue while trying to use the dokan-rust package and reported the issue there together with steps to reproduce it with the memfs example.

@inetic
Copy link
Author

inetic commented May 11, 2023

My knee-jerk fix would be to keep a flag of whether FindFilesWithPatter returned STATUS_NOT_IMPLEMENTED and pass that information from DispatchDirectoryInformation all the way to MatchFiles. But perhaps there is a better way.

@Liryna
Copy link
Member

Liryna commented May 17, 2023

Hi @inetic ,

Thank you for the report and the guidance how to fix it. Very impressive for catching this 💪

I have implemented your fix by using a BOOLEAN in the context of the open as the result of the FindFiles could be requery if needed
0e6dc66

Let me know what you think !

@inetic
Copy link
Author

inetic commented May 18, 2023

Thank you @Liryna, this looks good to me.

@inetic inetic closed this as completed May 18, 2023
@KoltesDigital
Copy link
Contributor

@inetic Thanks for the finding!

@Liryna Would you release a new patch version? So that language bindings could be released as well.

@Liryna
Copy link
Member

Liryna commented May 22, 2023

I would like but I am facing some difficulty to get an EV Certificate right now to do the release. It might take some time...

@hamflx
Copy link

hamflx commented Oct 21, 2023

The latest version v2.0.6.1000 still doesn't seem to include this patch. https://github.com/dokan-dev/dokany/blob/v2.0.6.1000/dokan/directory.c#L701-L706

Are there any plans to release this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants