Skip to content

Inaccurate boundary validation in Buffer.prototype.writeUIntBE/LE(value,offset,byteLength) #3497

Description

@kotarondo

The expression
new Buffer(1).writeUIntBE(0x100,0,1)
should throw an out-of-bounds error, but it does not.

In the source code, value validation is coded as follows:
checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0);

Here, max value should be Math.pow(2, 8 * byteLength) - 1 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions