fix(cryptoops): add nil check in SecureConnection.Read to prevent panic

Prevents a potential nil pointer dereference when sc.readBuffer is uninitialized, ensuring safe access to its .B field in the Read method.

lemon-mint committed Nov 18, 2025 at 15:34 UTC 8415764a10c2a7cda539f9cdaa1c3c68e47abf49
1 file changed +1 -1
portal/core/cryptoops/handshaker.go
+1 -1
@@ -190,7 +190,7 @@ func (sc *SecureConnection) writeFragmentation(p []byte) (int, error) {
190
191 // Read reads and decrypts data from the underlying connection
192 func (sc *SecureConnection) Read(p []byte) (int, error) {
193 - if len(sc.readBuffer.B) > 0 {
193 + if sc.readBuffer != nil && len(sc.readBuffer.B) > 0 {
194 n := copy(p, sc.readBuffer.B)
195 copy(sc.readBuffer.B[:len(sc.readBuffer.B)-n], sc.readBuffer.B[n:])
196 sc.readBuffer.B = sc.readBuffer.B[:len(sc.readBuffer.B)-n]