@@ -211,10 +211,10 @@ library Asn1Decode {
211
211
function readNodeLength (bytes memory der , uint256 ix ) private pure returns (Asn1Ptr) {
212
212
require (der[ix] & 0x1f != 0x1f , "ASN.1 tags longer than 1-byte are not supported " );
213
213
uint256 length;
214
- uint80 ixFirstContentByte;
214
+ uint256 ixFirstContentByte;
215
215
if ((der[ix + 1 ] & 0x80 ) == 0 ) {
216
216
length = uint8 (der[ix + 1 ]);
217
- ixFirstContentByte = uint80 ( ix + 2 ) ;
217
+ ixFirstContentByte = ix + 2 ;
218
218
} else {
219
219
uint8 lengthbytesLength = uint8 (der[ix + 1 ] & 0x7F );
220
220
if (lengthbytesLength == 1 ) {
@@ -223,10 +223,11 @@ library Asn1Decode {
223
223
length = der.readUint16 (ix + 2 );
224
224
} else {
225
225
length = uint256 (readBytesN (der, ix + 2 , lengthbytesLength) >> (32 - lengthbytesLength) * 8 );
226
+ require (length <= 2 ** 64 - 1 ); // bound to max uint64 to be safe
226
227
}
227
- ixFirstContentByte = uint80 ( ix + 2 + lengthbytesLength) ;
228
+ ixFirstContentByte = ix + 2 + lengthbytesLength;
228
229
}
229
- return LibAsn1Ptr.toAsn1Ptr (ix, ixFirstContentByte, uint80 ( length) );
230
+ return LibAsn1Ptr.toAsn1Ptr (ix, ixFirstContentByte, length);
230
231
}
231
232
232
233
function readBytesN (bytes memory self , uint256 idx , uint256 len ) private pure returns (bytes32 ret ) {
0 commit comments