From 8741da3e45876f8c55ca062a08726f542f646423 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 13 Sep 2017 14:23:59 -0700 Subject: Revert "Fix js conformance tests. (#3604)" (#3633) This reverts commit 2bd55a9fbcd2815b3332bf309bc20f59eef0b36b. --- js/compatibility_tests/v3.0.0/binary/decoder_test.js | 19 ++++++++++++++++++- js/compatibility_tests/v3.1.0/binary/decoder_test.js | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'js/compatibility_tests') diff --git a/js/compatibility_tests/v3.0.0/binary/decoder_test.js b/js/compatibility_tests/v3.0.0/binary/decoder_test.js index fce2fe18..ac312648 100644 --- a/js/compatibility_tests/v3.0.0/binary/decoder_test.js +++ b/js/compatibility_tests/v3.0.0/binary/decoder_test.js @@ -228,7 +228,24 @@ describe('binaryDecoderTest', function() { assertThrows(function() {decoder.readSignedVarint64()}); decoder.reset(); assertThrows(function() {decoder.readZigzagVarint64()}); - decoder.reset(); + + // Positive 32-bit varints encoded with 1 bits in positions 33 through 35 + // should trigger assertions. + decoder.setBlock([255, 255, 255, 255, 0x1F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 0x2F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 0x4F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + // Negative 32-bit varints encoded with non-1 bits in the high dword should + // trigger assertions. + decoder.setBlock([255, 255, 255, 255, 255, 255, 0, 255, 255, 1]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 255, 255, 255, 255, 255, 0]); assertThrows(function() {decoder.readUnsignedVarint32()}); }); diff --git a/js/compatibility_tests/v3.1.0/binary/decoder_test.js b/js/compatibility_tests/v3.1.0/binary/decoder_test.js index fce2fe18..ac312648 100644 --- a/js/compatibility_tests/v3.1.0/binary/decoder_test.js +++ b/js/compatibility_tests/v3.1.0/binary/decoder_test.js @@ -228,7 +228,24 @@ describe('binaryDecoderTest', function() { assertThrows(function() {decoder.readSignedVarint64()}); decoder.reset(); assertThrows(function() {decoder.readZigzagVarint64()}); - decoder.reset(); + + // Positive 32-bit varints encoded with 1 bits in positions 33 through 35 + // should trigger assertions. + decoder.setBlock([255, 255, 255, 255, 0x1F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 0x2F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 0x4F]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + // Negative 32-bit varints encoded with non-1 bits in the high dword should + // trigger assertions. + decoder.setBlock([255, 255, 255, 255, 255, 255, 0, 255, 255, 1]); + assertThrows(function() {decoder.readUnsignedVarint32()}); + + decoder.setBlock([255, 255, 255, 255, 255, 255, 255, 255, 255, 0]); assertThrows(function() {decoder.readUnsignedVarint32()}); }); -- cgit v1.2.3