On Fri Sep 20 10:13:56 2024 +0000, Jinoh Kang wrote:
Hello! I see that this is the second time contributing to ntdll. Congrats! In case you're not familiar with `UNICODE_STRING`, the `MaximumLength` should be at least `Length + 2`. So I guess the correct code should read:
curdir.MaximumLength = max(curdir.Length + 2, MAX_PATH * sizeof(WCHAR));
However, I'm not sure if DOS paths longer than 260 characters are even valid. We need to test how Windows behaves in this case (does it truncate? does it use a short name? does it extend MaximumLength like you did?)
It would seem that on Windows 10, the maximum length is 32,767 characters, but that requires a registry setting plus each application having a flag present in the application manifest:
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-lim...
I suspect we're not interested in implementing this same behaviour at the moment. It's certainly not guaranteed that Wine will be happy with it in all places (or indeed the underlying OS - macOS having a practical limit of around 1024 characters), but the application I was testing seems to work OK with longer paths with these fixes applied. The behaviour as it stands is definitely wrong though.
I'm happy to go with your suggestion regarding `+ 2`. I don't know how easy it would be to write a useful test for this; I have no idea if Windows stores the parameters in `Environment` in the same way as Wine.