зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1791029 - Deal with lstat potentially lying in nsLocalFileUnix. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D158796
This commit is contained in:
Родитель
ae203c5f2c
Коммит
633b70954e
|
@ -1911,9 +1911,13 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) {
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (readlink(mPath.get(), target.BeginWriting(), (size_t)size) < 0) {
|
||||
ssize_t written = readlink(mPath.get(), target.BeginWriting(), size_t(size));
|
||||
if (written < 0) {
|
||||
return NSRESULT_FOR_ERRNO();
|
||||
}
|
||||
// Target might have changed since the lstat call, or lstat might lie, see bug
|
||||
// 1791029.
|
||||
target.Truncate(written);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIFile> self(this);
|
||||
|
@ -1961,12 +1965,13 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) {
|
|||
break;
|
||||
}
|
||||
|
||||
int32_t linkLen =
|
||||
ssize_t linkLen =
|
||||
readlink(flatRetval.get(), newTarget.BeginWriting(), size);
|
||||
if (linkLen == -1) {
|
||||
rv = NSRESULT_FOR_ERRNO();
|
||||
break;
|
||||
}
|
||||
newTarget.Truncate(linkLen);
|
||||
target = newTarget;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче