Skip to content

Throw when decoding empty Buffers #209

Open

Description

@gmaclennan

There are a few places where we decode buffers in the protobuf message into a hex string, e.g. docId. These could be an empty buffer, which would be invalid.

Anywhere we are decoding a Protobuf type bytes (e.g. that decodes to Buffer), we should assert buf.length > 0. I don't think we should make any other assertions about these fields, to support the most forwards compatibility (e.g. they might be 32 bytes now, but we might change that in the future), so the only thing to check is zero-length.

Related: #115

  • Decoding a versionId, coreDiscoveryKey could be a Buffer of any length. We should check it is length 32.
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions