fix: Cbor.encode(BigInt(n)) possible failure#624
fix: Cbor.encode(BigInt(n)) possible failure#624neeboo wants to merge 4 commits intodfinity:mainfrom
Conversation
|
Dear @neeboo, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA1. If you decide to agree with it, please visit this issue and read the instructions there. — The DFINITY Foundation Footnotes
|
|
Dear @neeboo, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA1. If you decide to agree with it, please visit this issue and read the instructions there. — The DFINITY Foundation Footnotes
|
Cbor.encode(BigInt(n)) possible failureCbor.encode(BigInt(n)) possible failure
Co-authored-by: Kyle Peacock <kylpeacock@gmail.com>
Cbor.encode(BigInt(n)) possible failure| * @param hex The hexadecimal string to use. | ||
| */ | ||
| export function fromHex(hex: string): ArrayBuffer { | ||
| //FIXME: always padding hex string length to be even |
There was a problem hiding this comment.
What's the rationale for this? Does decoding break for odd-length hex strings?
| } | ||
| // // if we log the time | ||
| // if (i % 100000 === 0) { | ||
| // console.log(`${new Date(Date.now()).toLocaleTimeString()} with ${i.toString()}`); |
There was a problem hiding this comment.
Is there a reason these comments are left in?
|
When serializing objects that contain Has some progress been made on this? |
Fix
Cbor.encode(BigInt(n))possible failureDescription
When use
Cbor.encode, if passed value is BigInt, first will run the BigInt encoder and transform BigInt value to be a hex string. However thisBigInt(n).toString(16)would probrably generate a hex string length not to be even, which won't pass the RegTest in thefromHexfunction.Fixes # (issue)
Added a zero-padding while passing hex string length is not even.
How Has This Been Tested?
test cases are in
cbor.tests.tsChecklist: