aboutsummaryrefslogtreecommitdiff
path: root/src/math/big/ratmarsh.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@google.com>2022-08-01 15:54:13 +0000
committerDmitri Shuralyov <dmitshur@google.com>2022-08-01 15:54:13 +0000
commit349da2d42d3193af7f54170ae842166e4571134a (patch)
treea0b59dc2dfa4440add9d954efe1908272933247a /src/math/big/ratmarsh.go
parent7d5078e3bf2d865526e8ec2d211f61b2fac2936f (diff)
parent15da892a4950a4caac987ee72c632436329f62d5 (diff)
downloadgo-349da2d42d3193af7f54170ae842166e4571134a.tar.gz
go-349da2d42d3193af7f54170ae842166e4571134a.zip
[dev.boringcrypto.go1.17] all: merge go1.17.13 into dev.boringcrypto.go1.17dev.boringcrypto.go1.17
Change-Id: Iaf4f2cb506aab9e22a5df5b937c38fc108f1e1c1
Diffstat (limited to 'src/math/big/ratmarsh.go')
-rw-r--r--src/math/big/ratmarsh.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/math/big/ratmarsh.go b/src/math/big/ratmarsh.go
index fbc7b6002d9..56102e845b7 100644
--- a/src/math/big/ratmarsh.go
+++ b/src/math/big/ratmarsh.go
@@ -45,12 +45,18 @@ func (z *Rat) GobDecode(buf []byte) error {
*z = Rat{}
return nil
}
+ if len(buf) < 5 {
+ return errors.New("Rat.GobDecode: buffer too small")
+ }
b := buf[0]
if b>>1 != ratGobVersion {
return fmt.Errorf("Rat.GobDecode: encoding version %d not supported", b>>1)
}
const j = 1 + 4
i := j + binary.BigEndian.Uint32(buf[j-4:j])
+ if len(buf) < int(i) {
+ return errors.New("Rat.GobDecode: buffer too small")
+ }
z.a.neg = b&1 != 0
z.a.abs = z.a.abs.setBytes(buf[j:i])
z.b.abs = z.b.abs.setBytes(buf[i:])