Skip to content

Integers should have no size limitation. #143

@issuefiler

Description

@issuefiler

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions