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

Unified Diff: mojo/public/js/bindings/codec.js

Issue 406993002: Validate incoming JS Message Headers Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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: mojo/public/js/bindings/codec.js
diff --git a/mojo/public/js/bindings/codec.js b/mojo/public/js/bindings/codec.js
index 9756f4a5d6b59ca478cc6187808c7a256556c308..8f27af1d8707cac83d3d700d454a4610598b6c0b 100644
--- a/mojo/public/js/bindings/codec.js
+++ b/mojo/public/js/bindings/codec.js
@@ -452,6 +452,10 @@ define("mojo/public/js/bindings/codec", [
var kMessageExpectsResponse = 1 << 0;
var kMessageIsResponse = 1 << 1;
+ // Message header is a struct, begins with a struct header.
+ var kNumBytesOffset = 0;
+ var kNumFieldsOffset = 4;
+
// Skip over num_bytes, num_fields, and message_name.
var kFlagsOffset = 4 + 4 + 4;
@@ -468,10 +472,23 @@ define("mojo/public/js/bindings/codec", [
setUint64(this.buffer.dataView, kRequestIDOffset, requestID);
};
- Message.prototype.getFlags = function() {
+ Message.prototype.getHeaderNumBytes = function() {
+ return this.buffer.dataView.getUint32(kNumBytesOffset, kHostIsLittleEndian);
+ };
+
+ Message.prototype.getHeaderNumFields = function() {
+ return this.buffer.dataView.getUint32(kNumFieldsOffset,
+ kHostIsLittleEndian);
+ };
+
+ Message.prototype.getHeaderFlags = function() {
return this.buffer.dataView.getUint32(kFlagsOffset, kHostIsLittleEndian);
};
+ Message.prototype.byteLength = function() {
+ return this.buffer.dataView.byteLength;
+ }
+
// MessageBuilder -----------------------------------------------------------
function MessageBuilder(messageName, payloadSize) {
@@ -772,6 +789,7 @@ define("mojo/public/js/bindings/codec", [
exports.kArrayHeaderSize = kArrayHeaderSize;
exports.kStructHeaderSize = kStructHeaderSize;
exports.kMessageHeaderSize = kMessageHeaderSize;
+ exports.kMessageWithRequestIDHeaderSize = kMessageWithRequestIDHeaderSize;
exports.kMessageExpectsResponse = kMessageExpectsResponse;
exports.kMessageIsResponse = kMessageIsResponse;
exports.Int8 = Int8;

Powered by Google App Engine
This is Rietveld 408576698