]> Cypherpunks repositories - gostls13.git/commit
encoding: reject negative runes in Encoding.WithPadding
authorJoe Tsai <joetsai@digital-static.net>
Thu, 22 Jun 2023 18:03:17 +0000 (11:03 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 17 Aug 2023 16:32:08 +0000 (16:32 +0000)
commit6c431fab3701b5f07357a358ab232062353f5bed
tree563d49768a57c5bc191a843132f85fcd59c2cb80
parent56076c3080022f595541932fb4cea379939ec313
encoding: reject negative runes in Encoding.WithPadding

A negative rune (other than NoPadding) makes no semantic sense.
Doing so relies on integer overflow of converting a rune to a byte
and would thus be equivalent to passing the positive byte value
of byte(padding).

This may cause existing code to panic.
An alternative is treat negative runes as equivalent to NoPadding.
However, the code already panics to report erroneous padding values,
so this is in line with the existing API.

Change-Id: I02499705519581598adc0c8525d90e25278dc056
Reviewed-on: https://go-review.googlesource.com/c/go/+/505236
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/encoding/base32/base32.go
src/encoding/base64/base64.go