Chromium Code Reviews| Index: mojo/public/js/bindings/validator.js |
| diff --git a/mojo/public/js/bindings/validator.js b/mojo/public/js/bindings/validator.js |
| index de756566224f09228b5bd6cd0443c1b6eaa8a619..d83987173992a66504ecccd32fa1db8c0d5adb6c 100644 |
| --- a/mojo/public/js/bindings/validator.js |
| +++ b/mojo/public/js/bindings/validator.js |
| @@ -176,7 +176,7 @@ define("mojo/public/js/bindings/validator", [ |
| } |
| Validator.prototype.validateStructPointer = function( |
| - offset, structClass, nullable) { |
| + offset, structClass, nullable) { |
| var structOffset = this.decodePointer(offset); |
| if (structOffset === null) |
| return validationError.ILLEGAL_POINTER; |
| @@ -188,6 +188,38 @@ define("mojo/public/js/bindings/validator", [ |
| return structClass.validate(this, structOffset); |
| } |
| + Validator.prototype.validateMapPointer = function( |
|
yzshen1
2014/10/15 22:22:13
This probably misses fixed-size array dimensions,
hansmuller
2014/10/16 20:11:04
I've integrated the patch with the fixed-size arra
|
| + offset, mapIsNullable, keyClass, valueClass, valueIsNullable) { |
| + var structOffset = this.decodePointer(offset); |
| + if (structOffset === null) |
| + return validationError.ILLEGAL_POINTER; |
| + |
| + if (structOffset === NULL_MOJO_POINTER) |
| + return mapIsNullable ? |
| + validationError.NONE : validationError.UNEXPECTED_NULL_POINTER; |
| + |
| + var mapEncodedSize = codec.kStructHeaderSize + codec.kMapStructPayloadSize; |
| + var err = this.validateStructHeader(structOffset, mapEncodedSize, 2); |
| + if (err !== validationError.NONE) |
| + return err; |
| + |
| + var keysArrayPointerOffset = structOffset + codec.kStructHeaderSize; |
| + err = this.validateArrayPointer( |
| + keysArrayPointerOffset, keyClass.encodedSize, 0, keyClass, false); |
| + if (err !== validationError.NONE) |
| + return err; |
| + |
| + var keysArrayOffset = this.decodePointer(keysArrayPointerOffset); |
| + var keysArrayLength = this.message.buffer.getUint32(keysArrayOffset + 4); |
| + |
| + var valuesArrayPointerOffset = keysArrayPointerOffset + 8; |
| + return this.validateArrayPointer(valuesArrayPointerOffset, |
| + valueClass.encodedSize, |
| + keysArrayLength, |
|
yzshen1
2014/10/15 22:22:13
This will detect the validation failure, but with
hansmuller
2014/10/16 20:11:04
I've changed this to first validate the keys and v
|
| + valueClass, |
| + valueIsNullable); |
| + } |
| + |
| Validator.prototype.validateStringPointer = function(offset, nullable) { |
| return this.validateArrayPointer( |
| offset, codec.Uint8.encodedSize, 0, codec.Uint8, nullable); |