mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1078640: Sanitize path used to load XPCOM on OSX. r=smichaud
This commit is contained in:
parent
09c3d855c0
commit
784410e413
@ -56,13 +56,29 @@ private:
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
UInt8 tempBuffer[MAXPATHLEN];
|
||||
nsresult rv;
|
||||
if (CFURLGetFileSystemRepresentation(executableURL, false, (UInt8*)aResult,
|
||||
if (CFURLGetFileSystemRepresentation(executableURL, false, tempBuffer,
|
||||
MAXPATHLEN)) {
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Sanitize path in case the app was launched from Terminal via './firefox'
|
||||
// for example.
|
||||
size_t readPos = 0;
|
||||
size_t writePos = 0;
|
||||
while (tempBuffer[readPos] != '\0') {
|
||||
if (tempBuffer[readPos] == '.' && tempBuffer[readPos + 1] == '/') {
|
||||
readPos += 2;
|
||||
}
|
||||
aResult[writePos] = tempBuffer[readPos];
|
||||
readPos++;
|
||||
writePos++;
|
||||
}
|
||||
aResult[writePos] = '\0';
|
||||
|
||||
CFRelease(executableURL);
|
||||
return rv;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user