OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of protobuf; | 5 part of protobuf; |
6 | 6 |
7 class CodedBufferReader { | 7 class CodedBufferReader { |
8 static const int DEFAULT_RECURSION_LIMIT = 64; | 8 static const int DEFAULT_RECURSION_LIMIT = 64; |
9 static const int DEFAULT_SIZE_LIMIT = 64 << 20; | 9 static const int DEFAULT_SIZE_LIMIT = 64 << 20; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 throw new InvalidProtocolBufferException.truncatedMessage(); | 60 throw new InvalidProtocolBufferException.truncatedMessage(); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void readGroup(int fieldNumber, GeneratedMessage message, | 64 void readGroup(int fieldNumber, GeneratedMessage message, |
65 ExtensionRegistry extensionRegistry) { | 65 ExtensionRegistry extensionRegistry) { |
66 if (_recursionDepth >= _recursionLimit) { | 66 if (_recursionDepth >= _recursionLimit) { |
67 throw new InvalidProtocolBufferException.recursionLimitExceeded(); | 67 throw new InvalidProtocolBufferException.recursionLimitExceeded(); |
68 } | 68 } |
69 ++_recursionDepth; | 69 ++_recursionDepth; |
70 message.mergeFromCodedBufferReader(this); | 70 message.mergeFromCodedBufferReader(this, extensionRegistry); |
Søren Gjesse
2015/06/22 07:25:01
Should there be a regression test for this bug?
skybrian
2015/06/23 02:35:33
Probably, but for now, a regression will be caught
| |
71 checkLastTagWas(makeTag(fieldNumber, WIRETYPE_END_GROUP)); | 71 checkLastTagWas(makeTag(fieldNumber, WIRETYPE_END_GROUP)); |
72 --_recursionDepth; | 72 --_recursionDepth; |
73 } | 73 } |
74 | 74 |
75 UnknownFieldSet readUnknownFieldSetGroup(int fieldNumber) { | 75 UnknownFieldSet readUnknownFieldSetGroup(int fieldNumber) { |
76 if (_recursionDepth >= _recursionLimit) { | 76 if (_recursionDepth >= _recursionLimit) { |
77 throw new InvalidProtocolBufferException.recursionLimitExceeded(); | 77 throw new InvalidProtocolBufferException.recursionLimitExceeded(); |
78 } | 78 } |
79 ++_recursionDepth; | 79 ++_recursionDepth; |
80 UnknownFieldSet unknownFieldSet = new UnknownFieldSet(); | 80 UnknownFieldSet unknownFieldSet = new UnknownFieldSet(); |
(...skipping 14 matching lines...) Expand all Loading... | |
95 'CodedBufferReader encountered an embedded string or message' | 95 'CodedBufferReader encountered an embedded string or message' |
96 ' which claimed to have negative size.'); | 96 ' which claimed to have negative size.'); |
97 } | 97 } |
98 | 98 |
99 int oldLimit = _currentLimit; | 99 int oldLimit = _currentLimit; |
100 _currentLimit = _bufferPos + length; | 100 _currentLimit = _bufferPos + length; |
101 if (_currentLimit > oldLimit) { | 101 if (_currentLimit > oldLimit) { |
102 throw new InvalidProtocolBufferException.truncatedMessage(); | 102 throw new InvalidProtocolBufferException.truncatedMessage(); |
103 } | 103 } |
104 ++_recursionDepth; | 104 ++_recursionDepth; |
105 message.mergeFromCodedBufferReader(this); | 105 message.mergeFromCodedBufferReader(this, extensionRegistry); |
106 checkLastTagWas(0); | 106 checkLastTagWas(0); |
107 --_recursionDepth; | 107 --_recursionDepth; |
108 _currentLimit = oldLimit; | 108 _currentLimit = oldLimit; |
109 } | 109 } |
110 | 110 |
111 int readEnum() => readInt32(); | 111 int readEnum() => readInt32(); |
112 int readInt32() => _readRawVarint32(); | 112 int readInt32() => _readRawVarint32(); |
113 Int64 readInt64() => _readRawVarint64(); | 113 Int64 readInt64() => _readRawVarint64(); |
114 int readUint32() => _readRawVarint32(false); | 114 int readUint32() => _readRawVarint32(false); |
115 Int64 readUint64() => _readRawVarint64(); | 115 Int64 readUint64() => _readRawVarint64(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 } | 208 } |
209 throw new InvalidProtocolBufferException.malformedVarint(); | 209 throw new InvalidProtocolBufferException.malformedVarint(); |
210 } | 210 } |
211 | 211 |
212 ByteData _readByteData(int sizeInBytes) { | 212 ByteData _readByteData(int sizeInBytes) { |
213 _checkLimit(sizeInBytes); | 213 _checkLimit(sizeInBytes); |
214 return new ByteData.view(_buffer.buffer, | 214 return new ByteData.view(_buffer.buffer, |
215 _buffer.offsetInBytes + _bufferPos - sizeInBytes, sizeInBytes); | 215 _buffer.offsetInBytes + _bufferPos - sizeInBytes, sizeInBytes); |
216 } | 216 } |
217 } | 217 } |
OLD | NEW |