[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #65128] Incorrect use of GetUserPreferredUILanguages() in langprefs
From: |
INVALID.NOREPLY |
Subject: |
[bug #65128] Incorrect use of GetUserPreferredUILanguages() in langprefs |
Date: |
Fri, 5 Jan 2024 07:34:18 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?65128>
Summary: Incorrect use of GetUserPreferredUILanguages() in
langprefs
Group: GNU gettext
Submitter: lrn
Submitted: Fri 05 Jan 2024 12:34:18 PM UTC
Category: End-user / runtime
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Fri 05 Jan 2024 12:34:18 PM UTC By: Anonymous
gettext-runtime/intl/langprefs.c:
1) Has incorrect prototype for GetUserPreferredUILanguages() - expects it to
return DWORD and the first argument to be ULONG
Actually, it returns BOOL and the first argument is DWORD (see
documentation[1])
2) Checks the return value from the first call to be 0 (failure) and the error
code to be STATUS_BUFFER_OVERFLOW (0-size buffer is too small for the return
string).
Actually, the pass-NULL-and-0-to-get-the-required-buffer-size trick is not an
error case, it's a regular, intended result. That is to say, the function
actually returns 1 (i.e. not 0), and doesn't set any error.
It might be that the function did work that way back in 2007 when KJK:Hyperion
first sent this patch, or maybe he used some obscure info he had due to
working on ReactOS at the time. Either way, this code doesn't work correctly
for me right now.
I propose the prototype to be changed to:
typedef BOOL (WINAPI *GetUserPreferredUILanguages_func) (DWORD, PULONG, PWSTR,
PULONG);
and the first return value check be changed to:
if (ret && bufsize > 0)
[1]:
https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserpreferreduilanguages
The change in prototype doesn't seem to be strictly necessary (i assume that
the size of these types is the same, thus the first argument and the return
value happen to work regardless), while the change to the return value check
logic definitely is.
Other references:
Original code submission:
https://savannah.gnu.org/bugs/index.php?43801
Me discussing related issues with gnulib devs
https://lists.gnu.org/archive/html/bug-gnulib/2018-03/msg00024.html
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65128>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #65128] Incorrect use of GetUserPreferredUILanguages() in langprefs,
INVALID.NOREPLY <=