-
Bug
-
Resolution: Fixed
-
P4
-
jfx22
-
b26
In RoActivation.cpp, we find:
wchar_t path[MAX_PATH];
wchar_t file[MAX_PATH];
if (GetSystemDirectory(path, sizeof(path) / sizeof(wchar_t)) == 0) {
return;
}
This is likely only a theoretical concern, but if the path to the system directory has more than "MAX_PATH-1" chars, "path" will be uninitialized, since the docs for GetSystemDirectory say:
"If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path, including the terminating null character."
While we are at it, we should replace this with an explicit call to GetSystemDirectoryW (it's equivalent, given that we compile with /DUNICODE, but since we are explicitly using wchar_t we should also explicitly use the wide version of the function).
We should also check the return value of wcscat_s in case the concatenation of "combase.dll" doesn't fit.
Suggested fix:
UNIT rval = GetSystemDirectoryW(path, sizeof(path) / sizeof(wchar_t)) == 0) {
if (rval == 0 || rval >= sizeof(path) / sizeof(wchar_t)) {
return;
}
...
memcpy_s(file, sizeof(file), path, sizeof(path));
if (wcscat_s(file, MAX_PATH-1, L"\\combase.dll") != 0) {
return;
}
wchar_t path[MAX_PATH];
wchar_t file[MAX_PATH];
if (GetSystemDirectory(path, sizeof(path) / sizeof(wchar_t)) == 0) {
return;
}
This is likely only a theoretical concern, but if the path to the system directory has more than "MAX_PATH-1" chars, "path" will be uninitialized, since the docs for GetSystemDirectory say:
"If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path, including the terminating null character."
While we are at it, we should replace this with an explicit call to GetSystemDirectoryW (it's equivalent, given that we compile with /DUNICODE, but since we are explicitly using wchar_t we should also explicitly use the wide version of the function).
We should also check the return value of wcscat_s in case the concatenation of "combase.dll" doesn't fit.
Suggested fix:
UNIT rval = GetSystemDirectoryW(path, sizeof(path) / sizeof(wchar_t)) == 0) {
if (rval == 0 || rval >= sizeof(path) / sizeof(wchar_t)) {
return;
}
...
memcpy_s(file, sizeof(file), path, sizeof(path));
if (wcscat_s(file, MAX_PATH-1, L"\\combase.dll") != 0) {
return;
}
- links to
-
Commit openjdk/jfx/56e07dbc
-
Review(master) openjdk/jfx/1498