mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 688882 - Investigate stack buffer overflow in nsLocalFile::EnsureShortPath. r=bsmedberg
--HG-- extra : rebase_source : c872ba5d7b05bd611ee5926e6b3f9e7432db913e
This commit is contained in:
parent
dca8c29990
commit
0ffa1961e1
@ -3105,12 +3105,14 @@ nsLocalFile::EnsureShortPath()
|
||||
if (!mShortWorkingPath.IsEmpty())
|
||||
return;
|
||||
|
||||
WCHAR thisshort[MAX_PATH];
|
||||
DWORD thisr = ::GetShortPathNameW(mWorkingPath.get(), thisshort,
|
||||
sizeof(thisshort));
|
||||
// If an error occurred (thisr == 0) thisshort is uninitialized memory!
|
||||
if (thisr != 0 && thisr < sizeof(thisshort))
|
||||
mShortWorkingPath.Assign(thisshort);
|
||||
WCHAR shortPath[MAX_PATH + 1];
|
||||
DWORD lengthNeeded = ::GetShortPathNameW(mWorkingPath.get(), shortPath,
|
||||
NS_ARRAY_LENGTH(shortPath));
|
||||
// If an error occurred then lengthNeeded is set to 0 or the length of the
|
||||
// needed buffer including NULL termination. If it succeeds the number of
|
||||
// wide characters not including NULL termination is returned.
|
||||
if (lengthNeeded != 0 && lengthNeeded < NS_ARRAY_LENGTH(shortPath))
|
||||
mShortWorkingPath.Assign(shortPath);
|
||||
else
|
||||
mShortWorkingPath.Assign(mWorkingPath);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user