Skip to content

encoding: inconsistent panic behavior for {hex,base32,base64}.Decode #58391

@dsnet

Description

@dsnet

CL 461958 introduced inconsistencies across two dimensions:

  • Encode still panics on output buffers too small, while Decode now treats such cases as an error. This inconsistency cannot be resolved since Encode does not report an error and could be an argument for why we should revert CL 461958.
  • The base32 and base64 packages share very similar API as hex, and their equivalent Decode functions still panic if the output buffer is too small. We should handle these cases in identical ways across packages.

Should we revert CL 461958 to maintain consistency between Encode and Decode?
Or should we roll forward with applying equivalent checks to base32 and base64?

I have a very minor preference for rolling back.

Related: the fact that Encode and Decode can panic is a sharp edge fixed by #53693.

\cc @bprosnitz @ianlancetaylor @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions