зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1078640: Sanitize path used to load XPCOM on OSX. r=smichaud
This commit is contained in:
Родитель
e0e5857283
Коммит
982813d646
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче