diff options
author | 6543 <6543@obermui.de> | 2020-09-01 16:01:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-01 10:01:23 -0400 |
commit | 3270e7a4435fceb757728dfc319fc04077a37caf (patch) | |
tree | 60dcaf02442e930c0b2c7bd7fe0f0b00190a402f /vendor/go.mongodb.org/mongo-driver/x | |
parent | 66843f22375b67a58746dac508b71200a96e68d6 (diff) | |
download | gitea-3270e7a4435fceb757728dfc319fc04077a37caf.tar.gz gitea-3270e7a4435fceb757728dfc319fc04077a37caf.zip |
[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger
* vendor
Diffstat (limited to 'vendor/go.mongodb.org/mongo-driver/x')
-rw-r--r-- | vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go index e61194ef27..2a20d2e075 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go +++ b/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore/bsoncore.go @@ -123,6 +123,9 @@ func ReadElement(src []byte) (Element, []byte, bool) { if elemLength > len(src) { return nil, src, false } + if elemLength < 0 { + return nil, src, false + } return src[:elemLength], src[elemLength:], true } @@ -723,13 +726,18 @@ func appendi32(dst []byte, i32 int32) []byte { // ReadLength reads an int32 length from src and returns the length and the remaining bytes. If // there aren't enough bytes to read a valid length, src is returned unomdified and the returned // bool will be false. -func ReadLength(src []byte) (int32, []byte, bool) { return readi32(src) } +func ReadLength(src []byte) (int32, []byte, bool) { + ln, src, ok := readi32(src) + if ln < 0 { + return ln, src, false + } + return ln, src, ok +} func readi32(src []byte) (int32, []byte, bool) { if len(src) < 4 { return 0, src, false } - return (int32(src[0]) | int32(src[1])<<8 | int32(src[2])<<16 | int32(src[3])<<24), src[4:], true } |