Integrated: 8335216: [windows] Missing error check for GetSystemDirectory in glass
Lukasz Kostyra
lkostyra at openjdk.org
Tue Jul 9 06:47:38 UTC 2024
On Mon, 8 Jul 2024 14:24:27 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:
> When GetSystemDirectory does not have enough space to output a path to Windows' system directory, it will return a different value than 0 (more notably, the amount of bytes actually needed including null terminator). This was not checked, so the very rare hypothetical situation where Windows' system directory is different than the "standard" `C:\Windows` and longer than MAX_PATH was not properly handled.
>
> For now I simply changed the code to print an error and exit. This could be improved further to instead dynamically allocate space for the system directory though.
>
> Other changes, also mentioned in the issue:
> - We use `wchar_t` explicitly here, so I changed `GetSystemDirectory` to `GetSystemDirectoryW` to ensure the code compiles even without UNICODE being defined
> - `wcscat_s` can potentially fail for the same reasons as above, so this situation is also handled now.
This pull request has now been integrated.
Changeset: 56e07dbc
Author: Lukasz Kostyra <lkostyra at openjdk.org>
URL: https://git.openjdk.org/jfx/commit/56e07dbc9b04af06fc8cd1970595d19cb77fea4a
Stats: 9 lines in 1 file changed: 7 ins; 0 del; 2 mod
8335216: [windows] Missing error check for GetSystemDirectory in glass
Reviewed-by: mstrauss, kcr
-------------
PR: https://git.openjdk.org/jfx/pull/1498
More information about the openjfx-dev
mailing list