Skip to content

VariantUtil.getMetadataMap reads from wrong position for non-array ByteBuffer; VariantBuilder.appendBinary mutates caller's ByteBuffer #3471

@rayokota

Description

@rayokota

Describe the bug, including details regarding any error messages, version, and platform.

Description:

  • getMetadataMap incorrect position

    In VariantUtil.getMetadataMap, the else-branch (read-only or non-array-backed
    ByteBuffer) computes the slice position incorrectly:

    slice(metadata, stringStart + offset)
    

    stringStart is relative to pos (metadata.position()), but the array-backed
    branch correctly adds pos:

    metadata.arrayOffset() + pos + stringStart + offset
    

    This causes incorrect dictionary parsing or exceptions when the metadata
    ByteBuffer has a non-zero position (e.g., when it is a slice of a larger buffer).

    The sibling method getMetadataKey does not have this bug because dataPos is
    computed as an absolute position.

  • appendBinary mutates caller's ByteBuffer

    VariantBuilder.appendBinary(ByteBuffer) calls .put(binary) which advances the
    caller's ByteBuffer position. The analogous method appendEncodedValue uses
    value.duplicate().get(...) to avoid this side effect.

Component(s)

Core

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions