diff options
author | Moonchild <moonchild@palemoon.org> | 2022-11-20 14:14:48 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-11-20 14:14:48 +0000 |
commit | e28860ba7f238f6202ed3c45292deefadbe4598d (patch) | |
tree | c8a847d7d18d41eb93b93bbf299e30ed887c2244 | |
parent | 49a96b1d91f96a1da19220138495dcb35996a66b (diff) | |
download | uxp-RB_20221122.tar.gz |
Revert "[XPCOM] Deal with lstat potentially lying in nsLocalFileUnix."RC_20221120_2RB_20221122
This reverts commit c127f58ef33bff7bbea7fb300bc858d9f8273aec.
-rw-r--r-- | xpcom/io/nsLocalFileUnix.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index a092d4c26a..8aa5ae433b 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1720,14 +1720,11 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) return NS_ERROR_OUT_OF_MEMORY; } - ssize_t written = readlink(mPath.get(), target.BeginWriting(), size_t(size)); - if (written < 0) { + if (readlink(mPath.get(), target, (size_t)size) < 0) { free(target); return NSRESULT_FOR_ERRNO(); } - // Target might have changed since the lstat call, or lstat might lie, see bug - // 1791029. - target.Truncate(written); + target[size] = '\0'; nsresult rv = NS_OK; nsCOMPtr<nsIFile> self(this); @@ -1778,15 +1775,12 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) size = newSize; } - ssize_t linkLen = readlink(flatRetval.get(), target, size); + int32_t linkLen = readlink(flatRetval.get(), target, size); if (linkLen == -1) { rv = NSRESULT_FOR_ERRNO(); break; } - // Target might have changed since the lstat call, or lstat might lie, see bug - // 1791029. - newTarget.Truncate(linkLen); - target = newTarget; + target[linkLen] = '\0'; } free(target); |