From e43da55e29af3eb8e963885403654f14a5fddb5a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 06:16:44 +0000 Subject: [PATCH] Bump github.com/libp2p/go-libp2p-core from 0.15.0 to 0.15.1 Bumps [github.com/libp2p/go-libp2p-core](https://github.com/libp2p/go-libp2p-core) from 0.15.0 to 0.15.1. - [Release notes](https://github.com/libp2p/go-libp2p-core/releases) - [Commits](https://github.com/libp2p/go-libp2p-core/compare/v0.15.0...v0.15.1) --- updated-dependencies: - dependency-name: github.com/libp2p/go-libp2p-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 3 +- go.sum | 4 +-- .../libp2p/go-libp2p-core/crypto/ecdsa.go | 32 +++++++++++++++---- .../libp2p/go-libp2p-core/crypto/ed25519.go | 15 +++++++-- .../go-libp2p-core/crypto/key_openssl.go | 12 +++++-- .../libp2p/go-libp2p-core/crypto/rsa_go.go | 28 ++++++++++++---- .../libp2p/go-libp2p-core/crypto/secp256k1.go | 23 ++++++++++--- .../go-libp2p-core/internal/catch/catch.go | 18 +++++++++++ .../go-libp2p-core/peer/addrinfo_serde.go | 8 +++-- .../libp2p/go-libp2p-core/peer/record.go | 11 +++++-- .../libp2p/go-libp2p-core/record/envelope.go | 4 ++- .../libp2p/go-libp2p-core/record/record.go | 6 +++- vendor/modules.txt | 4 +-- 13 files changed, 131 insertions(+), 37 deletions(-) create mode 100644 vendor/github.com/libp2p/go-libp2p-core/internal/catch/catch.go diff --git a/go.mod b/go.mod index 3b501e4ec1..df62724cea 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/hashicorp/hcl v1.0.0 github.com/hashicorp/vault/api v1.3.1 github.com/libp2p/go-libp2p v0.18.0-rc2 - github.com/libp2p/go-libp2p-core v0.15.0 + github.com/libp2p/go-libp2p-core v0.15.1 github.com/libp2p/go-libp2p-kbucket v0.4.7 github.com/libp2p/go-libp2p-noise v0.3.0 github.com/libp2p/go-libp2p-pubsub v0.6.1 @@ -53,7 +53,6 @@ require ( github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/valyala/fastjson v1.6.3 // indirect go.uber.org/zap v1.20.0 // indirect - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect golang.org/x/tools v0.1.9 // indirect google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect diff --git a/go.sum b/go.sum index f28dea5a21..731a024866 100644 --- a/go.sum +++ b/go.sum @@ -597,8 +597,8 @@ github.com/libp2p/go-libp2p-core v0.10.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQR github.com/libp2p/go-libp2p-core v0.11.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg= github.com/libp2p/go-libp2p-core v0.12.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg= github.com/libp2p/go-libp2p-core v0.14.0/go.mod h1:tLasfcVdTXnixsLB0QYaT1syJOhsbrhG7q6pGrHtBg8= -github.com/libp2p/go-libp2p-core v0.15.0 h1:hKpgy/bRVwO7Ah5x9u92Vo+gogAaOolafZF5kW0rVm0= -github.com/libp2p/go-libp2p-core v0.15.0/go.mod h1:agSaboYM4hzB1cWekgVReqV5M4g5M+2eNNejV+1EEhs= +github.com/libp2p/go-libp2p-core v0.15.1 h1:0RY+Mi/ARK9DgG1g9xVQLb8dDaaU8tCePMtGALEfBnM= +github.com/libp2p/go-libp2p-core v0.15.1/go.mod h1:agSaboYM4hzB1cWekgVReqV5M4g5M+2eNNejV+1EEhs= github.com/libp2p/go-libp2p-discovery v0.6.0 h1:1XdPmhMJr8Tmj/yUfkJMIi8mgwWrLUsCB3bMxdT+DSo= github.com/libp2p/go-libp2p-discovery v0.6.0/go.mod h1:/u1voHt0tKIe5oIA1RHBKQLVCWPna2dXmPNHc2zR9S8= github.com/libp2p/go-libp2p-kbucket v0.4.7 h1:spZAcgxifvFZHBD8tErvppbnNiKA5uokDu3CV7axu70= diff --git a/vendor/github.com/libp2p/go-libp2p-core/crypto/ecdsa.go b/vendor/github.com/libp2p/go-libp2p-core/crypto/ecdsa.go index a693ef15e9..5b8244734f 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/crypto/ecdsa.go +++ b/vendor/github.com/libp2p/go-libp2p-core/crypto/ecdsa.go @@ -11,6 +11,7 @@ import ( "math/big" pb "github.com/libp2p/go-libp2p-core/crypto/pb" + "github.com/libp2p/go-libp2p-core/internal/catch" "github.com/minio/sha256-simd" ) @@ -73,17 +74,21 @@ func ECDSAPublicKeyFromPubKey(pub ecdsa.PublicKey) (PubKey, error) { } // MarshalECDSAPrivateKey returns x509 bytes from a private key -func MarshalECDSAPrivateKey(ePriv ECDSAPrivateKey) ([]byte, error) { +func MarshalECDSAPrivateKey(ePriv ECDSAPrivateKey) (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA private-key marshal") }() return x509.MarshalECPrivateKey(ePriv.priv) } // MarshalECDSAPublicKey returns x509 bytes from a public key -func MarshalECDSAPublicKey(ePub ECDSAPublicKey) ([]byte, error) { +func MarshalECDSAPublicKey(ePub ECDSAPublicKey) (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA public-key marshal") }() return x509.MarshalPKIXPublicKey(ePub.pub) } // UnmarshalECDSAPrivateKey returns a private key from x509 bytes -func UnmarshalECDSAPrivateKey(data []byte) (PrivKey, error) { +func UnmarshalECDSAPrivateKey(data []byte) (res PrivKey, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA private-key unmarshal") }() + priv, err := x509.ParseECPrivateKey(data) if err != nil { return nil, err @@ -93,7 +98,9 @@ func UnmarshalECDSAPrivateKey(data []byte) (PrivKey, error) { } // UnmarshalECDSAPublicKey returns the public key from x509 bytes -func UnmarshalECDSAPublicKey(data []byte) (PubKey, error) { +func UnmarshalECDSAPublicKey(data []byte) (key PubKey, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA public-key unmarshal") }() + pubIfc, err := x509.ParsePKIXPublicKey(data) if err != nil { return nil, err @@ -113,7 +120,8 @@ func (ePriv *ECDSAPrivateKey) Type() pb.KeyType { } // Raw returns x509 bytes from a private key -func (ePriv *ECDSAPrivateKey) Raw() ([]byte, error) { +func (ePriv *ECDSAPrivateKey) Raw() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA private-key marshal") }() return x509.MarshalECPrivateKey(ePriv.priv) } @@ -123,7 +131,8 @@ func (ePriv *ECDSAPrivateKey) Equals(o Key) bool { } // Sign returns the signature of the input data -func (ePriv *ECDSAPrivateKey) Sign(data []byte) ([]byte, error) { +func (ePriv *ECDSAPrivateKey) Sign(data []byte) (sig []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ECDSA signing") }() hash := sha256.Sum256(data) r, s, err := ecdsa.Sign(rand.Reader, ePriv.priv, hash[:]) if err != nil { @@ -157,7 +166,16 @@ func (ePub *ECDSAPublicKey) Equals(o Key) bool { } // Verify compares data to a signature -func (ePub *ECDSAPublicKey) Verify(data, sigBytes []byte) (bool, error) { +func (ePub *ECDSAPublicKey) Verify(data, sigBytes []byte) (success bool, err error) { + defer func() { + catch.HandlePanic(recover(), &err, "ECDSA signature verification") + + // Just to be extra paranoid. + if err != nil { + success = false + } + }() + sig := new(ECDSASig) if _, err := asn1.Unmarshal(sigBytes, sig); err != nil { return false, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/crypto/ed25519.go b/vendor/github.com/libp2p/go-libp2p-core/crypto/ed25519.go index b7e8addb8f..90713c23aa 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/crypto/ed25519.go +++ b/vendor/github.com/libp2p/go-libp2p-core/crypto/ed25519.go @@ -9,6 +9,7 @@ import ( "io" pb "github.com/libp2p/go-libp2p-core/crypto/pb" + "github.com/libp2p/go-libp2p-core/internal/catch" ) // Ed25519PrivateKey is an ed25519 private key. @@ -74,7 +75,9 @@ func (k *Ed25519PrivateKey) GetPublic() PubKey { } // Sign returns a signature from an input message. -func (k *Ed25519PrivateKey) Sign(msg []byte) ([]byte, error) { +func (k *Ed25519PrivateKey) Sign(msg []byte) (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "ed15519 signing") }() + return ed25519.Sign(k.k, msg), nil } @@ -99,7 +102,15 @@ func (k *Ed25519PublicKey) Equals(o Key) bool { } // Verify checks a signature agains the input data. -func (k *Ed25519PublicKey) Verify(data []byte, sig []byte) (bool, error) { +func (k *Ed25519PublicKey) Verify(data []byte, sig []byte) (success bool, err error) { + defer func() { + catch.HandlePanic(recover(), &err, "ed15519 signature verification") + + // To be safe. + if err != nil { + success = false + } + }() return ed25519.Verify(k.k, data, sig), nil } diff --git a/vendor/github.com/libp2p/go-libp2p-core/crypto/key_openssl.go b/vendor/github.com/libp2p/go-libp2p-core/crypto/key_openssl.go index 63fcca8e78..1a85ab4487 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/crypto/key_openssl.go +++ b/vendor/github.com/libp2p/go-libp2p-core/crypto/key_openssl.go @@ -12,16 +12,19 @@ import ( btcec "github.com/btcsuite/btcd/btcec" openssl "github.com/libp2p/go-openssl" + + "github.com/libp2p/go-libp2p-core/internal/catch" ) // KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys -func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { +func KeyPairFromStdKey(priv crypto.PrivateKey) (_priv PrivKey, _pub PubKey, err error) { if priv == nil { return nil, nil, ErrNilPrivateKey } switch p := priv.(type) { case *rsa.PrivateKey: + defer func() { catch.HandlePanic(recover(), &err, "x509 private key marshaling") }() pk, err := openssl.LoadPrivateKeyFromDER(x509.MarshalPKCS1PrivateKey(p)) if err != nil { return nil, nil, err @@ -48,12 +51,13 @@ func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { } // PrivKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) private keys -func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) { +func PrivKeyToStdKey(priv PrivKey) (_priv crypto.PrivateKey, err error) { if priv == nil { return nil, ErrNilPrivateKey } switch p := priv.(type) { case *opensslPrivateKey: + defer func() { catch.HandlePanic(recover(), &err, "x509 private key parsing") }() raw, err := p.Raw() if err != nil { return nil, err @@ -71,13 +75,15 @@ func PrivKeyToStdKey(priv PrivKey) (crypto.PrivateKey, error) { } // PubKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) public keys -func PubKeyToStdKey(pub PubKey) (crypto.PublicKey, error) { +func PubKeyToStdKey(pub PubKey) (key crypto.PublicKey, err error) { if pub == nil { return nil, ErrNilPublicKey } switch p := pub.(type) { case *opensslPublicKey: + defer func() { catch.HandlePanic(recover(), &err, "x509 public key parsing") }() + raw, err := p.Raw() if err != nil { return nil, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/crypto/rsa_go.go b/vendor/github.com/libp2p/go-libp2p-core/crypto/rsa_go.go index 3ae4731aa6..b0df60d98e 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/crypto/rsa_go.go +++ b/vendor/github.com/libp2p/go-libp2p-core/crypto/rsa_go.go @@ -12,6 +12,7 @@ import ( "io" pb "github.com/libp2p/go-libp2p-core/crypto/pb" + "github.com/libp2p/go-libp2p-core/internal/catch" "github.com/minio/sha256-simd" ) @@ -42,9 +43,17 @@ func GenerateRSAKeyPair(bits int, src io.Reader) (PrivKey, PubKey, error) { } // Verify compares a signature against input data -func (pk *RsaPublicKey) Verify(data, sig []byte) (bool, error) { +func (pk *RsaPublicKey) Verify(data, sig []byte) (success bool, err error) { + defer func() { + catch.HandlePanic(recover(), &err, "RSA signature verification") + + // To be safe + if err != nil { + success = false + } + }() hashed := sha256.Sum256(data) - err := rsa.VerifyPKCS1v15(&pk.k, crypto.SHA256, hashed[:], sig) + err = rsa.VerifyPKCS1v15(&pk.k, crypto.SHA256, hashed[:], sig) if err != nil { return false, err } @@ -55,7 +64,8 @@ func (pk *RsaPublicKey) Type() pb.KeyType { return pb.KeyType_RSA } -func (pk *RsaPublicKey) Raw() ([]byte, error) { +func (pk *RsaPublicKey) Raw() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "RSA public-key marshaling") }() return x509.MarshalPKIXPublicKey(&pk.k) } @@ -71,7 +81,8 @@ func (pk *RsaPublicKey) Equals(k Key) bool { } // Sign returns a signature of the input data -func (sk *RsaPrivateKey) Sign(message []byte) ([]byte, error) { +func (sk *RsaPrivateKey) Sign(message []byte) (sig []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "RSA signing") }() hashed := sha256.Sum256(message) return rsa.SignPKCS1v15(rand.Reader, &sk.sk, crypto.SHA256, hashed[:]) } @@ -85,7 +96,8 @@ func (sk *RsaPrivateKey) Type() pb.KeyType { return pb.KeyType_RSA } -func (sk *RsaPrivateKey) Raw() ([]byte, error) { +func (sk *RsaPrivateKey) Raw() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "RSA private-key marshaling") }() b := x509.MarshalPKCS1PrivateKey(&sk.sk) return b, nil } @@ -106,7 +118,8 @@ func (sk *RsaPrivateKey) Equals(k Key) bool { } // UnmarshalRsaPrivateKey returns a private key from the input x509 bytes -func UnmarshalRsaPrivateKey(b []byte) (PrivKey, error) { +func UnmarshalRsaPrivateKey(b []byte) (key PrivKey, err error) { + defer func() { catch.HandlePanic(recover(), &err, "RSA private-key unmarshaling") }() sk, err := x509.ParsePKCS1PrivateKey(b) if err != nil { return nil, err @@ -118,7 +131,8 @@ func UnmarshalRsaPrivateKey(b []byte) (PrivKey, error) { } // UnmarshalRsaPublicKey returns a public key from the input x509 bytes -func UnmarshalRsaPublicKey(b []byte) (PubKey, error) { +func UnmarshalRsaPublicKey(b []byte) (key PubKey, err error) { + defer func() { catch.HandlePanic(recover(), &err, "RSA public-key unmarshaling") }() pub, err := x509.ParsePKIXPublicKey(b) if err != nil { return nil, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/crypto/secp256k1.go b/vendor/github.com/libp2p/go-libp2p-core/crypto/secp256k1.go index 7936a09e13..9197f62fe2 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/crypto/secp256k1.go +++ b/vendor/github.com/libp2p/go-libp2p-core/crypto/secp256k1.go @@ -5,6 +5,7 @@ import ( "io" pb "github.com/libp2p/go-libp2p-core/crypto/pb" + "github.com/libp2p/go-libp2p-core/internal/catch" "github.com/btcsuite/btcd/btcec" "github.com/minio/sha256-simd" @@ -28,17 +29,19 @@ func GenerateSecp256k1Key(src io.Reader) (PrivKey, PubKey, error) { } // UnmarshalSecp256k1PrivateKey returns a private key from bytes -func UnmarshalSecp256k1PrivateKey(data []byte) (PrivKey, error) { +func UnmarshalSecp256k1PrivateKey(data []byte) (k PrivKey, err error) { if len(data) != btcec.PrivKeyBytesLen { return nil, fmt.Errorf("expected secp256k1 data size to be %d", btcec.PrivKeyBytesLen) } + defer func() { catch.HandlePanic(recover(), &err, "secp256k1 private-key unmarshal") }() privk, _ := btcec.PrivKeyFromBytes(btcec.S256(), data) return (*Secp256k1PrivateKey)(privk), nil } // UnmarshalSecp256k1PublicKey returns a public key from bytes -func UnmarshalSecp256k1PublicKey(data []byte) (PubKey, error) { +func UnmarshalSecp256k1PublicKey(data []byte) (_k PubKey, err error) { + defer func() { catch.HandlePanic(recover(), &err, "secp256k1 public-key unmarshal") }() k, err := btcec.ParsePubKey(data, btcec.S256()) if err != nil { return nil, err @@ -68,7 +71,8 @@ func (k *Secp256k1PrivateKey) Equals(o Key) bool { } // Sign returns a signature from input data -func (k *Secp256k1PrivateKey) Sign(data []byte) ([]byte, error) { +func (k *Secp256k1PrivateKey) Sign(data []byte) (_sig []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "secp256k1 signing") }() hash := sha256.Sum256(data) sig, err := (*btcec.PrivateKey)(k).Sign(hash[:]) if err != nil { @@ -89,7 +93,8 @@ func (k *Secp256k1PublicKey) Type() pb.KeyType { } // Raw returns the bytes of the key -func (k *Secp256k1PublicKey) Raw() ([]byte, error) { +func (k *Secp256k1PublicKey) Raw() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "secp256k1 public key marshaling") }() return (*btcec.PublicKey)(k).SerializeCompressed(), nil } @@ -104,7 +109,15 @@ func (k *Secp256k1PublicKey) Equals(o Key) bool { } // Verify compares a signature against the input data -func (k *Secp256k1PublicKey) Verify(data []byte, sigStr []byte) (bool, error) { +func (k *Secp256k1PublicKey) Verify(data []byte, sigStr []byte) (success bool, err error) { + defer func() { + catch.HandlePanic(recover(), &err, "secp256k1 signature verification") + + // To be extra safe. + if err != nil { + success = false + } + }() sig, err := btcec.ParseDERSignature(sigStr, btcec.S256()) if err != nil { return false, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/internal/catch/catch.go b/vendor/github.com/libp2p/go-libp2p-core/internal/catch/catch.go new file mode 100644 index 0000000000..c61ee2aa3d --- /dev/null +++ b/vendor/github.com/libp2p/go-libp2p-core/internal/catch/catch.go @@ -0,0 +1,18 @@ +package catch + +import ( + "fmt" + "io" + "os" + "runtime/debug" +) + +var panicWriter io.Writer = os.Stderr + +// HandlePanic handles and logs panics. +func HandlePanic(rerr interface{}, err *error, where string) { + if rerr != nil { + fmt.Fprintf(panicWriter, "caught panic: %s\n%s\n", rerr, debug.Stack()) + *err = fmt.Errorf("panic in %s: %s", where, rerr) + } +} diff --git a/vendor/github.com/libp2p/go-libp2p-core/peer/addrinfo_serde.go b/vendor/github.com/libp2p/go-libp2p-core/peer/addrinfo_serde.go index cef144fbe5..eae253d122 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/peer/addrinfo_serde.go +++ b/vendor/github.com/libp2p/go-libp2p-core/peer/addrinfo_serde.go @@ -3,6 +3,7 @@ package peer import ( "encoding/json" + "github.com/libp2p/go-libp2p-core/internal/catch" ma "github.com/multiformats/go-multiaddr" ) @@ -12,7 +13,9 @@ type addrInfoJson struct { Addrs []string } -func (pi AddrInfo) MarshalJSON() ([]byte, error) { +func (pi AddrInfo) MarshalJSON() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "libp2p addr info marshal") }() + addrs := make([]string, len(pi.Addrs)) for i, addr := range pi.Addrs { addrs[i] = addr.String() @@ -23,7 +26,8 @@ func (pi AddrInfo) MarshalJSON() ([]byte, error) { }) } -func (pi *AddrInfo) UnmarshalJSON(b []byte) error { +func (pi *AddrInfo) UnmarshalJSON(b []byte) (err error) { + defer func() { catch.HandlePanic(recover(), &err, "libp2p addr info unmarshal") }() var data addrInfoJson if err := json.Unmarshal(b, &data); err != nil { return err diff --git a/vendor/github.com/libp2p/go-libp2p-core/peer/record.go b/vendor/github.com/libp2p/go-libp2p-core/peer/record.go index 212cea721b..aae1d76ad3 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/peer/record.go +++ b/vendor/github.com/libp2p/go-libp2p-core/peer/record.go @@ -5,6 +5,7 @@ import ( "sync" "time" + "github.com/libp2p/go-libp2p-core/internal/catch" pb "github.com/libp2p/go-libp2p-core/peer/pb" "github.com/libp2p/go-libp2p-core/record" @@ -160,13 +161,15 @@ func (r *PeerRecord) Codec() []byte { // This method is called automatically when consuming a record.Envelope // whose PayloadType indicates that it contains a PeerRecord. // It is generally not necessary or recommended to call this method directly. -func (r *PeerRecord) UnmarshalRecord(bytes []byte) error { +func (r *PeerRecord) UnmarshalRecord(bytes []byte) (err error) { if r == nil { return fmt.Errorf("cannot unmarshal PeerRecord to nil receiver") } + defer func() { catch.HandlePanic(recover(), &err, "libp2p peer record unmarshal") }() + var msg pb.PeerRecord - err := proto.Unmarshal(bytes, &msg) + err = proto.Unmarshal(bytes, &msg) if err != nil { return err } @@ -183,7 +186,9 @@ func (r *PeerRecord) UnmarshalRecord(bytes []byte) error { // MarshalRecord serializes a PeerRecord to a byte slice. // This method is called automatically when constructing a routing.Envelope // using Seal or PeerRecord.Sign. -func (r *PeerRecord) MarshalRecord() ([]byte, error) { +func (r *PeerRecord) MarshalRecord() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "libp2p peer record marshal") }() + msg, err := r.ToProtobuf() if err != nil { return nil, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/record/envelope.go b/vendor/github.com/libp2p/go-libp2p-core/record/envelope.go index 10115910a0..df1eee7a3c 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/record/envelope.go +++ b/vendor/github.com/libp2p/go-libp2p-core/record/envelope.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/libp2p/go-libp2p-core/crypto" + "github.com/libp2p/go-libp2p-core/internal/catch" pb "github.com/libp2p/go-libp2p-core/record/pb" pool "github.com/libp2p/go-buffer-pool" @@ -192,7 +193,8 @@ func UnmarshalEnvelope(data []byte) (*Envelope, error) { // Marshal returns a byte slice containing a serialized protobuf representation // of a Envelope. -func (e *Envelope) Marshal() ([]byte, error) { +func (e *Envelope) Marshal() (res []byte, err error) { + defer func() { catch.HandlePanic(recover(), &err, "libp2p envelope marshal") }() key, err := crypto.PublicKeyToProto(e.PublicKey) if err != nil { return nil, err diff --git a/vendor/github.com/libp2p/go-libp2p-core/record/record.go b/vendor/github.com/libp2p/go-libp2p-core/record/record.go index 212005780e..af30a47e1a 100644 --- a/vendor/github.com/libp2p/go-libp2p-core/record/record.go +++ b/vendor/github.com/libp2p/go-libp2p-core/record/record.go @@ -3,6 +3,8 @@ package record import ( "errors" "reflect" + + "github.com/libp2p/go-libp2p-core/internal/catch" ) var ( @@ -70,7 +72,9 @@ func RegisterType(prototype Record) { payloadTypeRegistry[string(prototype.Codec())] = getValueType(prototype) } -func unmarshalRecordPayload(payloadType []byte, payloadBytes []byte) (Record, error) { +func unmarshalRecordPayload(payloadType []byte, payloadBytes []byte) (_rec Record, err error) { + defer func() { catch.HandlePanic(recover(), &err, "libp2p envelope record unmarshal") }() + rec, err := blankRecordForPayloadType(payloadType) if err != nil { return nil, err diff --git a/vendor/modules.txt b/vendor/modules.txt index 43b8a0adb7..2597cc9662 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -279,7 +279,7 @@ github.com/libp2p/go-libp2p/p2p/protocol/ping github.com/libp2p/go-libp2p-asn-util # github.com/libp2p/go-libp2p-blankhost v0.3.0 github.com/libp2p/go-libp2p-blankhost -# github.com/libp2p/go-libp2p-core v0.15.0 +# github.com/libp2p/go-libp2p-core v0.15.1 ## explicit github.com/libp2p/go-libp2p-core/connmgr github.com/libp2p/go-libp2p-core/control @@ -288,6 +288,7 @@ github.com/libp2p/go-libp2p-core/crypto/pb github.com/libp2p/go-libp2p-core/discovery github.com/libp2p/go-libp2p-core/event github.com/libp2p/go-libp2p-core/host +github.com/libp2p/go-libp2p-core/internal/catch github.com/libp2p/go-libp2p-core/introspection github.com/libp2p/go-libp2p-core/introspection/pb github.com/libp2p/go-libp2p-core/metrics @@ -626,7 +627,6 @@ golang.org/x/net/ipv6 golang.org/x/net/route golang.org/x/net/trace # golang.org/x/sync v0.0.0-20210220032951-036812b2e83c -## explicit golang.org/x/sync/errgroup # golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 ## explicit