HACK: windows: Work around broken AssocQueryStringW() not returning actual string length#114
HACK: windows: Work around broken AssocQueryStringW() not returning actual string length#114amodm merged 1 commit intoamodm:mainfrom
AssocQueryStringW() not returning actual string length#114Conversation
… actual string length
Wine has a bug where calling `AssocQueryStringW()` with a buffer doesn't
actually update `line_len` to the actual number of bytes returned,
resulting in `webbrowser` failing on seeing a bunch of unexpected `nul`
bytes in the array:
Error { kind: InvalidInput, message: "nul byte found in provided data" }
This is reported and fixed upstream via:
https://bugs.winehq.org/show_bug.cgi?id=59402
https://gitlab.winehq.org/wine/wine/-/merge_requests/10072
I still need to write tests to get it merged, and even then it might
take a while to trickle down into releases and ultimately Steam Proton.
Hence have this ugly workaround to catch cases where `nul` characters
end up in the output and reduce the string length by hand.
amodm
left a comment
There was a problem hiding this comment.
Thanks, @MarijnS95. I appreciate your continued contributions to maintaining this crate.
I was initially considering if we should replace the condition with if line_len == BUF_SIZE && is_wine(), but on more thought I'm not fully sure if it adds any further value. If line_len == BUF_SIZE, then most likely we're in a bad situation anyway, and the only way out is scanning for null terminator.
Given that this scenario exposed a bug related to line_len, I'm wondering if the check should instead be a stricter: if line_len >= BUF_SIZE. But I'll let it be your call.
The PR LGTM. But if you're marked it as draft, so I'll wait for you to update its status, post which I'll merge & release.
|
@amodm thanks! This was marked draft because I wasn't too happy with having a windows-emulation-specific workaround in client code, but in hindsight the extra validation probably doesn't hurt. The specific wine condition only happens where Neither case should pass through because of Allowing this fallback path through for those scenarios too with the suggested In any other case where There's one argument to be made that my workaround code (and trace log) also triggers for the one valid case where the string including NUL character is exactly Footnotes
|
|
This is now out as v1.2.1. About return the raw os error, I'm not fully sure because any meaningful use of it will involve the caller to have platform specific interpretation which isn't a good API for this crate IMHO. Alternatively, if we were to think of such an API change as a diagnostic tool only, perhaps that's probably better handled via logging instead of returning a code. |
|
Awesome, thanks for the quick release! You're right that having such a low-level error isn't too useful in the public API, but using the dynamic |
Wine has a bug where calling
AssocQueryStringW()with a buffer doesn't actually updateline_lento the actual number of bytes returned, resulting inwebbrowserfailing on seeing a bunch of unexpectednulbytes in the array:This is reported and fixed upstream via:
https://bugs.winehq.org/show_bug.cgi?id=59402
https://gitlab.winehq.org/wine/wine/-/merge_requests/10072
I still need to write tests to get it merged, and even then it might take a while to trickle down into releases and ultimately Steam Proton. Hence have this ugly workaround to catch cases where
nulcharacters end up in the output and reduce the string length by hand.