summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlli Pettay <Olli.Pettay@helsinki.fi>2021-12-08 17:10:16 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-03 01:03:41 +0200
commit6be1a97ba044f0bec7d6f9f4ad585ebba54d9c37 (patch)
tree682cd67ebdfe1701d7a97ab0f585236fbcabf295
parentd9888688d0ceaa77cb16140c5c8ea48ed37f255b (diff)
downloaduxp-6be1a97ba044f0bec7d6f9f4ad585ebba54d9c37.tar.gz
[DOM] Don't try to create too large string buffers
-rw-r--r--dom/base/nsStructuredCloneContainer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/dom/base/nsStructuredCloneContainer.cpp b/dom/base/nsStructuredCloneContainer.cpp
index 6e3a692568..fb9f0286d5 100644
--- a/dom/base/nsStructuredCloneContainer.cpp
+++ b/dom/base/nsStructuredCloneContainer.cpp
@@ -15,6 +15,7 @@
#include "xpcpublic.h"
#include "mozilla/Base64.h"
+#include "mozilla/CheckedInt.h"
#include "mozilla/dom/ScriptSettings.h"
using namespace mozilla;
@@ -138,6 +139,11 @@ nsStructuredCloneContainer::GetDataAsBase64(nsAString &aOut)
auto iter = Data().Start();
size_t size = Data().Size();
+ CheckedInt<nsAutoCString::size_type> sizeCheck(size);
+ if (!sizeCheck.isValid()) {
+ return NS_ERROR_FAILURE;
+ }
+
nsAutoCString binaryData;
binaryData.SetLength(size);
Data().ReadBytes(iter, binaryData.BeginWriting(), size);