Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp

Issue 1739613002: DevTools: validate protocol input parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined a test. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp
index 25cd3d316f7e5ea559f2fb5bfefc55b9134fd17d..6e0f2b6929773facdf05c09f5524b8f4c40ea446 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorLayerTreeAgent.cpp
@@ -350,15 +350,7 @@ void InspectorLayerTreeAgent::loadSnapshot(ErrorString* errorString, PassOwnPtr<
Vector<RefPtr<PictureSnapshot::TilePictureStream>> decodedTiles;
decodedTiles.grow(tiles->length());
for (size_t i = 0; i < tiles->length(); ++i) {
- OwnPtr<protocol::LayerTree::PictureTile> tile = tiles->get(i);
- if (!tile) {
- *errorString = "Invalid argument, array item is not an object";
- return;
- }
- if (!tile->hasX() || !tile->hasY() || !tile->hasPicture()) {
- *errorString = "Invalid argument, missing required field";
- return;
- }
+ protocol::LayerTree::PictureTile* tile = tiles->get(i);
decodedTiles[i] = adoptRef(new PictureSnapshot::TilePictureStream());
decodedTiles[i]->layerOffset.set(tile->getX(), tile->getY());
if (!base64Decode(tile->getPicture(), decodedTiles[i]->data)) {
@@ -418,12 +410,9 @@ void InspectorLayerTreeAgent::replaySnapshot(ErrorString* errorString, const Str
*dataURL = url.toString();
}
-static bool parseRect(protocol::DOM::Rect* object, FloatRect* rect)
+static void parseRect(protocol::DOM::Rect* object, FloatRect* rect)
{
- if (!object->hasX() || !object->hasY() || !object->hasWidth() || !object->hasHeight())
- return false;
*rect = FloatRect(object->getX(), object->getY(), object->getWidth(), object->getHeight());
- return true;
}
void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const String& snapshotId, const protocol::Maybe<int>& minRepeatCount, const protocol::Maybe<double>& minDuration, const Maybe<protocol::DOM::Rect>& clipRect, OwnPtr<protocol::Array<protocol::Array<double>>>* outTimings)
@@ -432,10 +421,8 @@ void InspectorLayerTreeAgent::profileSnapshot(ErrorString* errorString, const St
if (!snapshot)
return;
FloatRect rect;
- if (clipRect.isJust() && !parseRect(clipRect.fromJust(), &rect)) {
- *errorString = "Invalid argument, missing required field";
- return;
- }
+ if (clipRect.isJust())
+ parseRect(clipRect.fromJust(), &rect);
OwnPtr<PictureSnapshot::Timings> timings = snapshot->profile(minRepeatCount.fromMaybe(1), minDuration.fromMaybe(0), clipRect.isJust() ? &rect : 0);
*outTimings = Array<Array<double>>::create();
for (size_t i = 0; i < timings->size(); ++i) {
@@ -452,7 +439,8 @@ void InspectorLayerTreeAgent::snapshotCommandLog(ErrorString* errorString, const
const PictureSnapshot* snapshot = snapshotById(errorString, snapshotId);
if (!snapshot)
return;
- *commandLog = Array<RefPtr<JSONObject>>::runtimeCast(snapshot->snapshotCommandLog());
+ protocol::ErrorSupport errors(errorString);
+ *commandLog = Array<RefPtr<JSONObject>>::parse(snapshot->snapshotCommandLog(), &errors);
}
void InspectorLayerTreeAgent::willAddPageOverlay(const GraphicsLayer* layer)

Powered by Google App Engine
This is Rietveld 408576698