mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-15 19:00:19 +00:00
171ba6a65d
Bumps the github-dependencies group with 8 updates in the / directory: | Package | From | To | | --- | --- | --- | | [github.com/IBM/keyprotect-go-client](https://github.com/IBM/keyprotect-go-client) | `0.12.2` | `0.14.1` | | [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) | `1.53.14` | `1.54.6` | | [github.com/aws/aws-sdk-go-v2/service/sts](https://github.com/aws/aws-sdk-go-v2) | `1.28.1` | `1.29.1` | | [github.com/hashicorp/vault/api](https://github.com/hashicorp/vault) | `1.12.0` | `1.14.0` | | [github.com/kubernetes-csi/csi-lib-utils](https://github.com/kubernetes-csi/csi-lib-utils) | `0.17.0` | `0.18.1` | | [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) | `2.17.1` | `2.19.0` | | [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) | `1.18.0` | `1.19.1` | | [github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://github.com/Azure/azure-sdk-for-go) | `1.6.0` | `1.7.0` | Updates `github.com/IBM/keyprotect-go-client` from 0.12.2 to 0.14.1 - [Release notes](https://github.com/IBM/keyprotect-go-client/releases) - [Changelog](https://github.com/IBM/keyprotect-go-client/blob/master/CHANGELOG.md) - [Commits](https://github.com/IBM/keyprotect-go-client/compare/v0.12.2...v0.14.1) Updates `github.com/aws/aws-sdk-go` from 1.53.14 to 1.54.6 - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.53.14...v1.54.6) Updates `github.com/aws/aws-sdk-go-v2/service/sts` from 1.28.1 to 1.29.1 - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/ecr/v1.28.1...service/s3/v1.29.1) Updates `github.com/hashicorp/vault/api` from 1.12.0 to 1.14.0 - [Release notes](https://github.com/hashicorp/vault/releases) - [Changelog](https://github.com/hashicorp/vault/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/vault/compare/v1.12.0...v1.14.0) Updates `github.com/kubernetes-csi/csi-lib-utils` from 0.17.0 to 0.18.1 - [Release notes](https://github.com/kubernetes-csi/csi-lib-utils/releases) - [Commits](https://github.com/kubernetes-csi/csi-lib-utils/compare/v0.17.0...v0.18.1) Updates `github.com/onsi/ginkgo/v2` from 2.17.1 to 2.19.0 - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.17.1...v2.19.0) Updates `github.com/onsi/gomega` from 1.32.0 to 1.33.1 - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.32.0...v1.33.1) Updates `github.com/prometheus/client_golang` from 1.18.0 to 1.19.1 - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](https://github.com/prometheus/client_golang/compare/v1.18.0...v1.19.1) Updates `github.com/Azure/azure-sdk-for-go/sdk/azidentity` from 1.6.0 to 1.7.0 - [Release notes](https://github.com/Azure/azure-sdk-for-go/releases) - [Changelog](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/release.md) - [Commits](https://github.com/Azure/azure-sdk-for-go/compare/sdk/azcore/v1.6.0...sdk/azcore/v1.7.0) --- updated-dependencies: - dependency-name: github.com/IBM/keyprotect-go-client dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/aws/aws-sdk-go-v2/service/sts dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/hashicorp/vault/api dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/kubernetes-csi/csi-lib-utils dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/prometheus/client_golang dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies - dependency-name: github.com/Azure/azure-sdk-for-go/sdk/azidentity dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-dependencies ... Signed-off-by: dependabot[bot] <support@github.com>
161 lines
4.6 KiB
Go
161 lines
4.6 KiB
Go
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package protodelim marshals and unmarshals varint size-delimited messages.
|
|
package protodelim
|
|
|
|
import (
|
|
"bufio"
|
|
"encoding/binary"
|
|
"fmt"
|
|
"io"
|
|
|
|
"google.golang.org/protobuf/encoding/protowire"
|
|
"google.golang.org/protobuf/internal/errors"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// MarshalOptions is a configurable varint size-delimited marshaler.
|
|
type MarshalOptions struct{ proto.MarshalOptions }
|
|
|
|
// MarshalTo writes a varint size-delimited wire-format message to w.
|
|
// If w returns an error, MarshalTo returns it unchanged.
|
|
func (o MarshalOptions) MarshalTo(w io.Writer, m proto.Message) (int, error) {
|
|
msgBytes, err := o.MarshalOptions.Marshal(m)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
sizeBytes := protowire.AppendVarint(nil, uint64(len(msgBytes)))
|
|
sizeWritten, err := w.Write(sizeBytes)
|
|
if err != nil {
|
|
return sizeWritten, err
|
|
}
|
|
msgWritten, err := w.Write(msgBytes)
|
|
if err != nil {
|
|
return sizeWritten + msgWritten, err
|
|
}
|
|
return sizeWritten + msgWritten, nil
|
|
}
|
|
|
|
// MarshalTo writes a varint size-delimited wire-format message to w
|
|
// with the default options.
|
|
//
|
|
// See the documentation for [MarshalOptions.MarshalTo].
|
|
func MarshalTo(w io.Writer, m proto.Message) (int, error) {
|
|
return MarshalOptions{}.MarshalTo(w, m)
|
|
}
|
|
|
|
// UnmarshalOptions is a configurable varint size-delimited unmarshaler.
|
|
type UnmarshalOptions struct {
|
|
proto.UnmarshalOptions
|
|
|
|
// MaxSize is the maximum size in wire-format bytes of a single message.
|
|
// Unmarshaling a message larger than MaxSize will return an error.
|
|
// A zero MaxSize will default to 4 MiB.
|
|
// Setting MaxSize to -1 disables the limit.
|
|
MaxSize int64
|
|
}
|
|
|
|
const defaultMaxSize = 4 << 20 // 4 MiB, corresponds to the default gRPC max request/response size
|
|
|
|
// SizeTooLargeError is an error that is returned when the unmarshaler encounters a message size
|
|
// that is larger than its configured [UnmarshalOptions.MaxSize].
|
|
type SizeTooLargeError struct {
|
|
// Size is the varint size of the message encountered
|
|
// that was larger than the provided MaxSize.
|
|
Size uint64
|
|
|
|
// MaxSize is the MaxSize limit configured in UnmarshalOptions, which Size exceeded.
|
|
MaxSize uint64
|
|
}
|
|
|
|
func (e *SizeTooLargeError) Error() string {
|
|
return fmt.Sprintf("message size %d exceeded unmarshaler's maximum configured size %d", e.Size, e.MaxSize)
|
|
}
|
|
|
|
// Reader is the interface expected by [UnmarshalFrom].
|
|
// It is implemented by *[bufio.Reader].
|
|
type Reader interface {
|
|
io.Reader
|
|
io.ByteReader
|
|
}
|
|
|
|
// UnmarshalFrom parses and consumes a varint size-delimited wire-format message
|
|
// from r.
|
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
|
//
|
|
// The error is [io.EOF] error only if no bytes are read.
|
|
// If an EOF happens after reading some but not all the bytes,
|
|
// UnmarshalFrom returns a non-io.EOF error.
|
|
// In particular if r returns a non-io.EOF error, UnmarshalFrom returns it unchanged,
|
|
// and if only a size is read with no subsequent message, [io.ErrUnexpectedEOF] is returned.
|
|
func (o UnmarshalOptions) UnmarshalFrom(r Reader, m proto.Message) error {
|
|
var sizeArr [binary.MaxVarintLen64]byte
|
|
sizeBuf := sizeArr[:0]
|
|
for i := range sizeArr {
|
|
b, err := r.ReadByte()
|
|
if err != nil {
|
|
// Immediate EOF is unexpected.
|
|
if err == io.EOF && i != 0 {
|
|
break
|
|
}
|
|
return err
|
|
}
|
|
sizeBuf = append(sizeBuf, b)
|
|
if b < 0x80 {
|
|
break
|
|
}
|
|
}
|
|
size, n := protowire.ConsumeVarint(sizeBuf)
|
|
if n < 0 {
|
|
return protowire.ParseError(n)
|
|
}
|
|
|
|
maxSize := o.MaxSize
|
|
if maxSize == 0 {
|
|
maxSize = defaultMaxSize
|
|
}
|
|
if maxSize != -1 && size > uint64(maxSize) {
|
|
return errors.Wrap(&SizeTooLargeError{Size: size, MaxSize: uint64(maxSize)}, "")
|
|
}
|
|
|
|
var b []byte
|
|
var err error
|
|
if br, ok := r.(*bufio.Reader); ok {
|
|
// Use the []byte from the bufio.Reader instead of having to allocate one.
|
|
// This reduces CPU usage and allocated bytes.
|
|
b, err = br.Peek(int(size))
|
|
if err == nil {
|
|
defer br.Discard(int(size))
|
|
} else {
|
|
b = nil
|
|
}
|
|
}
|
|
if b == nil {
|
|
b = make([]byte, size)
|
|
_, err = io.ReadFull(r, b)
|
|
}
|
|
|
|
if err == io.EOF {
|
|
return io.ErrUnexpectedEOF
|
|
}
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := o.Unmarshal(b, m); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// UnmarshalFrom parses and consumes a varint size-delimited wire-format message
|
|
// from r with the default options.
|
|
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
|
//
|
|
// See the documentation for [UnmarshalOptions.UnmarshalFrom].
|
|
func UnmarshalFrom(r Reader, m proto.Message) error {
|
|
return UnmarshalOptions{}.UnmarshalFrom(r, m)
|
|
}
|