You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
The encode function of the Codec class successfully encodes integers larger than expected.
Calling the decode method of the Codec class on this encoded data fails, breaking the round-trip property of the encode and decode functions.
Recommendation: Add checks in the code to prevent integers larger than the maximum value or smaller than the minimum value cannot be encoded or decoded.
Steps to reproduce
This issue can be replicated with the test shown below, in which a value of 2100 is successfully encoded as a uint64 (while the maximum value should be 264-1).
describe('uint_validation', () => {
const schema_uint64 = {
$id: 'test/uint_validation',
type: 'object',
required: ['amount'],
properties: {
amount: {
dataType: 'uint64',
fieldNumber: 1,
},
}, };
it('uint64 encoding with larger than expected values', () => {
expect(codec.encode(schema_uint64, { amount: BigInt(2) ** BigInt(100) })).toThrow(); // This does not throw
});
});
Which version(s) does this affect? (Environment, OS, etc...)
v6.1.0-beta.1
The text was updated successfully, but these errors were encountered:
Description
The encode function of the Codec class successfully encodes integers larger than expected.
Calling the decode method of the Codec class on this encoded data fails, breaking the round-trip property of the encode and decode functions.
Recommendation: Add checks in the code to prevent integers larger than the maximum value or smaller than the minimum value cannot be encoded or decoded.
Steps to reproduce
This issue can be replicated with the test shown below, in which a value of 2100 is successfully encoded as a uint64 (while the maximum value should be 264-1).
Which version(s) does this affect? (Environment, OS, etc...)
v6.1.0-beta.1
The text was updated successfully, but these errors were encountered: