From 362e5836f1468aa7f158d5da157c0e99da334d06 Mon Sep 17 00:00:00 2001 From: sukun Date: Sat, 26 Oct 2024 03:15:39 +0530 Subject: [PATCH] pnet: wrap underlying error when reading nonce fails (#2975) --- p2p/net/pnet/psk_conn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p2p/net/pnet/psk_conn.go b/p2p/net/pnet/psk_conn.go index c600c8d093..b36d434904 100644 --- a/p2p/net/pnet/psk_conn.go +++ b/p2p/net/pnet/psk_conn.go @@ -3,6 +3,7 @@ package pnet import ( "crypto/cipher" "crypto/rand" + "fmt" "io" "net" @@ -33,7 +34,7 @@ func (c *pskConn) Read(out []byte) (int, error) { nonce := make([]byte, 24) _, err := io.ReadFull(c.Conn, nonce) if err != nil { - return 0, errShortNonce + return 0, fmt.Errorf("%w: %w", errShortNonce, err) } c.readS20 = salsa20.New(c.psk, nonce) }