Skip to content

[BUG] Invalid buf size or offsets not detected #847

@broofa

Description

@broofa

Description of the problem

Reporting on behalf of @gaoyia

Recipe for reproducing

import { stringify, v4 } from 'uuid';

const buf = new Uint8Array(16);
v4({}, buf, -8); // Invalid offset should throw, but doesn't
console.log(buf);  // Uint8Array(16) [... (8 bytes),  0, 0, 0, 0, 0, 0, 0, 0]
stringify(buf); // Throws!

Similarly...

const buf = new Uint8Array(15); // Note: 15 bytes, not 16
v4({}, buf); // Invalid buf size should throw, but doesn't
console.log(buf); // [... 15 bytes ...]
stringify(buf); // Throws!

Additional information

No response

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions