Bug 1078640: Sanitize path used to load XPCOM on OSX. r=smichaud

This commit is contained in:
Stephen Pohl 2014-10-07 09:33:09 -04:00
Родитель e0e5857283
Коммит 982813d646
1 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -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;
}