summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulie Jeongeun Kim <jkim@igalia.com>2019-12-12 09:37:13 +0000
committerMichael BrĂ¼ning <michael.bruning@qt.io>2020-07-29 10:49:36 +0000
commit199df5c9049603476903d1f1166c8d161db8f6ee (patch)
treef61a2fe7587b2729a1db41493be0468c78e7e0b8
parent8b2ba2a1e56c4d95f6bd7c6df630e800d8e34eb3 (diff)
downloadqtwebengine-chromium-199df5c9049603476903d1f1166c8d161db8f6ee.tar.gz
[Backport] Dependency for CVE-2020-6534 (4/4)
Manual backport of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/1961827: Use [RaisesException] for immediate promise rejections in peerconnection This is a part of effort for using [RaisesException] when synchronously rejecting a promise. It uses [RaisesException] for //third_party/blink/renderer/modules/peerconnection. Bug: 1001114 Change-Id: I0d309be08a87e99af777a802301f55242c367057 Reviewed-by: Guido Urdaneta <guidou@chromium.org> Commit-Queue: Julie Kim <jkim@igalia.com> Cr-Commit-Position: refs/heads/master@{#724165} Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc103
-rw-r--r--chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h18
-rw-r--r--chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.idl8
3 files changed, 70 insertions, 59 deletions
diff --git a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
index 3acd6169f9c..823c37c62b6 100644
--- a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
+++ b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
@@ -637,12 +637,13 @@ void RTCPeerConnection::Dispose() {
}
ScriptPromise RTCPeerConnection::createOffer(ScriptState* script_state,
- const RTCOfferOptions& options) {
+ const RTCOfferOptions& options,
+ ExceptionState& exception_state) {
if (signaling_state_ ==
webrtc::PeerConnectionInterface::SignalingState::kClosed) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(DOMExceptionCode::kInvalidStateError,
- kSignalingStateClosedMessage));
+ exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
+ kSignalingStateClosedMessage);
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
@@ -723,12 +724,13 @@ ScriptPromise RTCPeerConnection::createOffer(
}
ScriptPromise RTCPeerConnection::createAnswer(ScriptState* script_state,
- const RTCAnswerOptions& options) {
+ const RTCAnswerOptions& options,
+ ExceptionState& exception_state) {
if (signaling_state_ ==
webrtc::PeerConnectionInterface::SignalingState::kClosed) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(DOMExceptionCode::kInvalidStateError,
- kSignalingStateClosedMessage));
+ exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
+ kSignalingStateClosedMessage);
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
@@ -826,12 +828,16 @@ DOMException* RTCPeerConnection::checkSdpForStateErrors(
ScriptPromise RTCPeerConnection::setLocalDescription(
ScriptState* script_state,
- const RTCSessionDescriptionInit& session_description_init) {
+ const RTCSessionDescriptionInit& session_description_init,
+ ExceptionState& exception_state) {
String sdp;
DOMException* exception = checkSdpForStateErrors(
ExecutionContext::From(script_state), session_description_init, &sdp);
if (exception) {
- return ScriptPromise::RejectWithDOMException(script_state, exception);
+ exception_state.ThrowDOMException(
+ static_cast<DOMExceptionCode>(exception->code()),
+ exception->message());
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
ScriptPromise promise = resolver->Promise();
@@ -893,12 +899,13 @@ RTCSessionDescription* RTCPeerConnection::localDescription() {
ScriptPromise RTCPeerConnection::setRemoteDescription(
ScriptState* script_state,
- const RTCSessionDescriptionInit& session_description_init) {
+ const RTCSessionDescriptionInit& session_description_init,
+ ExceptionState& exception_state) {
if (signaling_state_ ==
webrtc::PeerConnectionInterface::SignalingState::kClosed) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(DOMExceptionCode::kInvalidStateError,
- kSignalingStateClosedMessage));
+ exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
+ kSignalingStateClosedMessage);
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
@@ -1058,10 +1065,9 @@ ScriptPromise RTCPeerConnection::generateCertificate(
key_params =
WebRTCKeyParams::CreateRSA(modulus_length, public_exponent);
} else {
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(DOMExceptionCode::kNotSupportedError,
- unsupported_params_string));
+ exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
+ unsupported_params_string);
+ return ScriptPromise();
}
break;
case kWebCryptoAlgorithmIdEcdsa:
@@ -1071,19 +1077,17 @@ ScriptPromise RTCPeerConnection::generateCertificate(
kWebCryptoNamedCurveP256) {
key_params = WebRTCKeyParams::CreateECDSA(kWebRTCECCurveNistP256);
} else {
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(DOMExceptionCode::kNotSupportedError,
- unsupported_params_string));
+ exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
+ unsupported_params_string);
+ return ScriptPromise();
}
break;
default:
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(DOMExceptionCode::kNotSupportedError,
- "The 1st argument provided is an "
- "AlgorithmIdentifier, but the "
- "algorithm is not supported."));
+ exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
+ "The 1st argument provided is an "
+ "AlgorithmIdentifier, but the "
+ "algorithm is not supported.");
+ return ScriptPromise();
break;
}
DCHECK(key_params.has_value());
@@ -1094,9 +1098,9 @@ ScriptPromise RTCPeerConnection::generateCertificate(
// |keyParams| was successfully constructed, but does the certificate
// generator support these parameters?
if (!certificate_generator->IsSupportedKeyParams(key_params.value())) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(DOMExceptionCode::kNotSupportedError,
- unsupported_params_string));
+ exception_state.ThrowDOMException(DOMExceptionCode::kNotSupportedError,
+ unsupported_params_string);
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
@@ -1129,9 +1133,9 @@ ScriptPromise RTCPeerConnection::addIceCandidate(
ExceptionState& exception_state) {
if (signaling_state_ ==
webrtc::PeerConnectionInterface::SignalingState::kClosed) {
- return ScriptPromise::RejectWithDOMException(
- script_state, DOMException::Create(DOMExceptionCode::kInvalidStateError,
- kSignalingStateClosedMessage));
+ exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
+ kSignalingStateClosedMessage);
+ return ScriptPromise();
}
if (IsIceCandidateMissingSdp(candidate)) {
@@ -1400,12 +1404,12 @@ ScriptPromise RTCPeerConnection::getStats(ScriptState* script_state,
// "getStats(optional MediaStreamTrack? selector)". null is a valid selector
// value, but a value of the wrong type isn't.
if (first_argument->IsNullOrUndefined())
- return PromiseBasedGetStats(script_state, nullptr);
+ return PromiseBasedGetStats(script_state, nullptr, exception_state);
MediaStreamTrack* track =
V8MediaStreamTrack::ToImplWithTypeCheck(isolate, first_argument);
if (track)
- return PromiseBasedGetStats(script_state, track);
+ return PromiseBasedGetStats(script_state, track, exception_state);
exception_state.ThrowTypeError(
"The argument provided as parameter 1 is neither a callback (function) "
@@ -1434,17 +1438,17 @@ ScriptPromise RTCPeerConnection::LegacyCallbackBasedGetStats(
ScriptPromise RTCPeerConnection::PromiseBasedGetStats(
ScriptState* script_state,
- MediaStreamTrack* selector) {
+ MediaStreamTrack* selector,
+ ExceptionState& exception_state) {
if (!selector) {
ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kRTCPeerConnectionGetStats);
if (!peer_handler_) {
LOG(ERROR) << "Internal error: peer_handler_ has been discarded";
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(DOMExceptionCode::kOperationError,
- "Internal error: release in progress"));
+ exception_state.ThrowDOMException(DOMExceptionCode::kOperationError,
+ "Internal error: release in progress");
+ return ScriptPromise();
}
ScriptPromiseResolver* resolver =
ScriptPromiseResolver::Create(script_state);
@@ -1472,17 +1476,16 @@ ScriptPromise RTCPeerConnection::PromiseBasedGetStats(
}
}
if (track_uses == 0u) {
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(DOMExceptionCode::kInvalidAccessError,
- "There is no sender or receiver for the track."));
+ exception_state.ThrowDOMException(
+ DOMExceptionCode::kInvalidAccessError,
+ "There is no sender or receiver for the track.");
+ return ScriptPromise();
}
if (track_uses > 1u) {
- return ScriptPromise::RejectWithDOMException(
- script_state,
- DOMException::Create(
- DOMExceptionCode::kInvalidAccessError,
- "There are more than one sender or receiver for the track."));
+ exception_state.ThrowDOMException(
+ DOMExceptionCode::kInvalidAccessError,
+ "There are more than one sender or receiver for the track.");
+ return ScriptPromise();
}
// There is just one use of the track, a sender or receiver.
if (track_sender) {
diff --git a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h
index b713ea3a5b9..251dce9be7c 100644
--- a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h
+++ b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h
@@ -91,21 +91,26 @@ class MODULES_EXPORT RTCPeerConnection final
ExceptionState&);
~RTCPeerConnection() override;
- ScriptPromise createOffer(ScriptState*, const RTCOfferOptions&);
+ ScriptPromise createOffer(ScriptState*,
+ const RTCOfferOptions&,
+ ExceptionState&);
ScriptPromise createOffer(ScriptState*,
V8RTCSessionDescriptionCallback*,
V8RTCPeerConnectionErrorCallback*,
const Dictionary&,
ExceptionState&);
- ScriptPromise createAnswer(ScriptState*, const RTCAnswerOptions&);
+ ScriptPromise createAnswer(ScriptState*,
+ const RTCAnswerOptions&,
+ ExceptionState&);
ScriptPromise createAnswer(ScriptState*,
V8RTCSessionDescriptionCallback*,
V8RTCPeerConnectionErrorCallback*,
const Dictionary&);
ScriptPromise setLocalDescription(ScriptState*,
- const RTCSessionDescriptionInit&);
+ const RTCSessionDescriptionInit&,
+ ExceptionState&);
ScriptPromise setLocalDescription(
ScriptState*,
const RTCSessionDescriptionInit&,
@@ -114,7 +119,8 @@ class MODULES_EXPORT RTCPeerConnection final
RTCSessionDescription* localDescription();
ScriptPromise setRemoteDescription(ScriptState*,
- const RTCSessionDescriptionInit&);
+ const RTCSessionDescriptionInit&,
+ ExceptionState&);
ScriptPromise setRemoteDescription(
ScriptState*,
const RTCSessionDescriptionInit&,
@@ -176,7 +182,9 @@ class MODULES_EXPORT RTCPeerConnection final
ScriptState*,
V8RTCStatsCallback* success_callback,
MediaStreamTrack* selector);
- ScriptPromise PromiseBasedGetStats(ScriptState*, MediaStreamTrack* selector);
+ ScriptPromise PromiseBasedGetStats(ScriptState*,
+ MediaStreamTrack* selector,
+ ExceptionState&);
const HeapVector<Member<RTCRtpTransceiver>>& getTransceivers() const;
const HeapVector<Member<RTCRtpSender>>& getSenders() const;
diff --git a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.idl b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.idl
index 25301e3ba52..8bcad3f2a5e 100644
--- a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.idl
+++ b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.idl
@@ -67,13 +67,13 @@ enum RTCIceConnectionState {
RaisesException=Constructor,
Exposed=Window
] interface RTCPeerConnection : EventTarget {
- [CallWith=ScriptState] Promise<RTCSessionDescription> createOffer(optional RTCOfferOptions options);
- [CallWith=ScriptState] Promise<RTCSessionDescription> createAnswer(optional RTCAnswerOptions options);
- [CallWith=ScriptState] Promise<void> setLocalDescription(RTCSessionDescriptionInit description);
+ [CallWith=ScriptState, RaisesException] Promise<RTCSessionDescription> createOffer(optional RTCOfferOptions options);
+ [CallWith=ScriptState, RaisesException] Promise<RTCSessionDescription> createAnswer(optional RTCAnswerOptions options);
+ [CallWith=ScriptState, RaisesException] Promise<void> setLocalDescription(optional RTCSessionDescriptionInit description);
readonly attribute RTCSessionDescription? localDescription;
// readonly attribute RTCSessionDescription? currentLocalDescription;
// readonly attribute RTCSessionDescription? pendingLocalDescription;
- [CallWith=ScriptState] Promise<void> setRemoteDescription(RTCSessionDescriptionInit description);
+ [CallWith=ScriptState, RaisesException] Promise<void> setRemoteDescription(RTCSessionDescriptionInit description);
readonly attribute RTCSessionDescription? remoteDescription;
// readonly attribute RTCSessionDescription? currentRemoteDescription;
// readonly attribute RTCSessionDescription? pendingRemoteDescription;