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

Unified Diff: src/core/SkFlattenableSerialization.cpp

Issue 22799007: I'm investigating how to make the IPC transfer a bit more secure on the (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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: src/core/SkFlattenableSerialization.cpp
diff --git a/src/core/SkFlattenableSerialization.cpp b/src/core/SkFlattenableSerialization.cpp
index b74c82f051648f77dce5da97b26e21ba53b12e4b..c6bce673f4bedc29c8913d09407d0b57d4a2baf4 100644
--- a/src/core/SkFlattenableSerialization.cpp
+++ b/src/core/SkFlattenableSerialization.cpp
@@ -9,6 +9,7 @@
#include "SkData.h"
#include "SkFlattenable.h"
+#include "SkImageFilter.h"
#include "SkOrderedReadBuffer.h"
#include "SkOrderedWriteBuffer.h"
@@ -26,3 +27,27 @@ SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size) {
SkOrderedReadBuffer buffer(data, size);
return buffer.readFlattenable();
}
+
+bool SkValidateImageFilterRec(SkFlattenable* flattenable) {
+ if (!flattenable
+ // This object should always have been sent cross-process,
+ // so it should always have a factory
+ || !flattenable->getFactory()
+ // Only SkImageFilter objects are allowed
+ || !flattenable->isA(SkFlattenable::IMAGE_FILTER))
+ return false;
+
+ // Check that all the inputs are also SkImageFilter objects
+ SkImageFilter* filter = static_cast<SkImageFilter*>(flattenable);
+ int nbInputs = filter->countInputs();
+ for (int i = 0; i < nbInputs; ++i)
+ if (!SkValidateImageFilterRec(filter->getInput(i)))
+ return false;
+
+ return true;
+}
+
+SkImageFilter* SkValidateImageFilter(SkFlattenable* flattenable) {
+ return SkValidateImageFilterRec(flattenable) ?
+ static_cast<SkImageFilter*>(flattenable) : 0;
+}

Powered by Google App Engine
This is Rietveld 408576698