Skip to content

JenkinsLookup3.decode can repeat a one-byte payload across an oversized output #894

Open

Description

@justavibedev

JenkinsLookup3.decode can repeat a one-byte payload across an oversized output array:

import numpy as np
from numcodecs import JenkinsLookup3

codec = JenkinsLookup3()
out = np.zeros(4, dtype="u1")
codec.decode(codec.encode(b"x"), out=out)
print(out.tobytes())  # b'xxxx'

The checksum is valid for b"x", but the four bytes returned to the caller are different. The codec API requires an output buffer of exactly the decoded size, so I expected a size error before any write.

Correctly sized buffers fail in the other direction. With a 12-byte payload, an output array of shape (2, 3) and dtype uint16 raises a broadcasting error, and a 12-byte bytearray raises an AttributeError. All three cases go through the Jenkins decoder's direct byte-view assignment.

Reproduced using the NumCodecs 0.17.1 and NumPy 2.5.4 wheels on CPython 3.12.11, macOS arm64. Codex assisted with reproduction.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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