Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integers should have no size limitation. #143

Open
issuefiler opened this issue May 21, 2023 · 0 comments
Open

Integers should have no size limitation. #143

issuefiler opened this issue May 21, 2023 · 0 comments

Comments

@issuefiler
Copy link

Bug: it fails to satisfy the specification.

BEP 52 — The BitTorrent protocol specification version 2

Integers have no size limitation.

Currently, node-bencode allows decoded integer data to be corrupted. It should either use bigints or throw on a long integer input.

function getIntFromBuffer (buffer, start, end) {
let sum = 0
let sign = 1
for (let i = start; i < end; i++) {
const num = buffer[i]
if (num < 58 && num >= 48) {
sum = sum * 10 + (num - 48)
continue
}

yourdecode("i9007199254740991e") === yourdecode("i9007199254740992e")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant