mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Sanity-check in nsStandardURL::Deserialize(). r=mayhemer, a=RyanVM
Also add test for faulty nsStandardURL deserialization. See Bug 1392739.
This commit is contained in:
parent
d8712492da
commit
bfe6f25a2d
2 changed files with 19 additions and 1 deletions
|
|
@ -3455,8 +3455,10 @@ FromIPCSegment(const nsACString& aSpec, const ipc::StandardURLSegment& aSegment,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckedInt<uint32_t> segmentLen = aSegment.position();
|
||||||
|
segmentLen += aSegment.length();
|
||||||
// Make sure the segment does not extend beyond the spec.
|
// Make sure the segment does not extend beyond the spec.
|
||||||
if (NS_WARN_IF(aSegment.position() + aSegment.length() > aSpec.Length())) {
|
if (NS_WARN_IF(!segmentLen.isValid() || segmentLen.value() > aSpec.Length())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,11 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsNetCID.h"
|
#include "nsNetCID.h"
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
|
#include "nsIStandardURL.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
|
#include "nsIIPCSerializableURI.h"
|
||||||
|
#include "mozilla/ipc/URIUtils.h"
|
||||||
|
|
||||||
TEST(TestStandardURL, Simple) {
|
TEST(TestStandardURL, Simple) {
|
||||||
nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
|
nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
|
||||||
|
|
@ -67,3 +70,16 @@ MOZ_GTEST_BENCH(TestStandardURL, Perf, [] {
|
||||||
url->GetRef(out);
|
url->GetRef(out);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TEST(TestStandardURL, Deserialize_Bug1392739)
|
||||||
|
{
|
||||||
|
mozilla::ipc::StandardURLParams standard_params;
|
||||||
|
standard_params.urlType() = nsIStandardURL::URLTYPE_STANDARD;
|
||||||
|
standard_params.spec() = NS_LITERAL_CSTRING("");
|
||||||
|
standard_params.host() = mozilla::ipc::StandardURLSegment(4294967295, 1);
|
||||||
|
|
||||||
|
mozilla::ipc::URIParams params(standard_params);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIIPCSerializableURI> url = do_CreateInstance(NS_STANDARDURL_CID);
|
||||||
|
ASSERT_EQ(url->Deserialize(params), false);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue