summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgproto3/v2/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/jackc/pgproto3/v2/backend.go')
-rw-r--r--vendor/github.com/jackc/pgproto3/v2/backend.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/vendor/github.com/jackc/pgproto3/v2/backend.go b/vendor/github.com/jackc/pgproto3/v2/backend.go
index 9c42ad02e..1f1436529 100644
--- a/vendor/github.com/jackc/pgproto3/v2/backend.go
+++ b/vendor/github.com/jackc/pgproto3/v2/backend.go
@@ -2,6 +2,7 @@ package pgproto3
import (
"encoding/binary"
+ "errors"
"fmt"
"io"
)
@@ -30,11 +31,10 @@ type Backend struct {
sync Sync
terminate Terminate
- bodyLen int
- msgType byte
- partialMsg bool
- authType uint32
-
+ bodyLen int
+ msgType byte
+ partialMsg bool
+ authType uint32
}
const (
@@ -115,6 +115,9 @@ func (b *Backend) Receive() (FrontendMessage, error) {
b.msgType = header[0]
b.bodyLen = int(binary.BigEndian.Uint32(header[1:])) - 4
b.partialMsg = true
+ if b.bodyLen < 0 {
+ return nil, errors.New("invalid message with negative body length received")
+ }
}
var msg FrontendMessage
@@ -147,6 +150,8 @@ func (b *Backend) Receive() (FrontendMessage, error) {
msg = &SASLResponse{}
case AuthTypeSASLFinal:
msg = &SASLResponse{}
+ case AuthTypeGSS, AuthTypeGSSCont:
+ msg = &GSSResponse{}
case AuthTypeCleartextPassword, AuthTypeMD5Password:
fallthrough
default: