Skip to content

Buffer.alloc(): uninitialized buffer with an incorrectly encoded fill value #17423

Closed
@vic511

Description

@vic511

Executing this script leads to buf being uninitialized.

let buf = Buffer.alloc(0x100, "This is not correctly encoded", "hex");
console.log(buf);

PoC

I highly suspect this is because Buffer.alloc() calls buffer.fill() after allocating memory, which doesn't fill the buffer when it cannot decode the value parameter.

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