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

Windows Network-Provider: wrong contents #952

Open
5 tasks done
uhonermann opened this issue Dec 16, 2020 · 7 comments
Open
5 tasks done

Windows Network-Provider: wrong contents #952

uhonermann opened this issue Dec 16, 2020 · 7 comments

Comments

@uhonermann
Copy link

uhonermann commented Dec 16, 2020

Feature request can skip this form. Bug report must complete it. Check List must be 100% match or it will be automatically closed without further discussion. Please remove this line.

Environment

  • Windows version: Windows 10
  • Processor architecture: x64
  • Dokany version: 1.4.0
  • Library type (Dokany/FUSE): 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

  • Contents of Dokany UNC are showing complete UNC, instead of sharenames only (in this case, only myshare should be shown):
    DokanyNPSharenames
  • Dokany Network-Provider responses to any UNC (in this case \whatever shows Dokan shares):
    DokanyNPAnyUNC

Logs

Please attach in separate files: mirror output, library logs and kernel logs.
In case of BSOD, please attach minidump or dump analyze output.

@uhonermann
Copy link
Author

I think I found the reason for the strange behaviour, and also the reason why the servername of the resoure in Windows Explorer Network Neighborhood is wrong (servername + "Dokan2).

There's in error in dokan_np, function EnumResource with Scope RESOURCE_GLOBALNET.
The servername is copied into the strings buffer without any terminating \0, whitch leads to a "concatenation" with the provider that is copied directly behind it:

    WCHAR *lpServerName = NULL;
    ULONG ulServerName = 0;
    parseServerName(&dokanMountPointInfo[pCtx->index].UNCName[1], &lpServerName,
      &ulServerName);

    /* Return server.
    * Determine the space needed for this entry.
    */
    cbEntry = sizeof(NETRESOURCE);
    cbEntry +=
      (2 + ulServerName) * sizeof(WCHAR); /* \\ + the server name */

Terminating Null is not taken into account when calculating size.

    pNetResource->lpRemoteName = pDst;
    *pDst++ = L'\\';
    *pDst++ = L'\\';
    CopyMemory(pDst, lpServerName, ulServerName * sizeof(WCHAR));
    pDst += ulServerName;

Terminating Null is not appended to servername in buffer.

@Liryna
Copy link
Member

Liryna commented Aug 2, 2022

Thanks @uhonermann for coming back to this issue and finding the solution! Would you be willing to open a pull request with the fix ?

@uhonermann
Copy link
Author

Hi Liryna,

I'm gonna setup a build environment, fix the issue and see, if this also solves some other problems we have with the Network Provider.
When I'm done, I'll open a PR.

@Liryna
Copy link
Member

Liryna commented Aug 13, 2022

Hi @uhonermann , I tried your fix of having a null terminating but I was still able to repro the issue. Let me know if you found otherwise.

@uhonermann
Copy link
Author

Hi @Liryna, I could solve the problem: "Windows Explorer Network Neighborhood is wrong (servername + Dokan2)", but the other problem (complete UNC instead of share name only) still persists.
Unfortunately, currently I don't have any idea, why this heapens.
It looks like the results of calls to the Network Provider are correct (compared with others, like VMWare), but it's still wrong only with the Dokan drive.

@Liryna
Copy link
Member

Liryna commented Aug 29, 2022

Hi @uhonermann , Nice! could you share how were you able to fix the "Windows Explorer Network Neighborhood is wrong (servername + Dokan2)" ?

@uhonermann
Copy link
Author

uhonermann commented Aug 29, 2022

Changes are quite minimal:

        cbEntry +=
          (2 + ulServerName) * sizeof(WCHAR); /* \\ + the server name */
-->
        cbEntry +=
          (2 + ulServerName + 1) * sizeof(WCHAR); /* \\ + the server name + terminator*/

And:

        CopyMemory(pDst, lpServerName, ulServerName * sizeof(WCHAR));
        pDst += ulServerName;
-->
        CopyMemory(pDst, lpServerName, ulServerName * sizeof(WCHAR));
        pDst += ulServerName;
        *pDst++ = L'\0';

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

2 participants