Skip to content

SetMaxElements equivalent for msgp.Unmarshaler interface #411

Description

@ajgajg1134

Hello!

I saw the recent update included support for setting the max elements (and a few other protections) for the reader based interface. Would you be open to adding this support via the generated code for the other msgp.Unmarshaler interface?

This would be useful for me in enabling fuzz testing where we make use of the msgp.Unmarshaler interface for performance reasons. Without these limits today fuzz testing isn't feasible as random inputs that allocate huge amounts of memory crash / stall the fuzzer.

I had a couple ideas on how one (possibly me?) could go about implementing this, but none stood out to me as "obviously the best"

  • Add package variables to the generated code that can be set at runtime to limit the sizes of allocated slices/dicts/strings etc (These would be overriden by any value set in the "Reader" if that is being used)
  • Add an option to the code generation itself where a fixed value is provided at compile time

I'm happy to give more details if needed, Thanks!

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