From 73bbced270612f0bc25ad2843534d60ff5933ee1 Mon Sep 17 00:00:00 2001 From: jennifersp Date: Fri, 23 Aug 2024 16:17:07 -0700 Subject: [PATCH] add byte length check to uint32 --- pgtype/uint32.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pgtype/uint32.go b/pgtype/uint32.go index c01341099..f2b2fa6d4 100644 --- a/pgtype/uint32.go +++ b/pgtype/uint32.go @@ -296,6 +296,10 @@ func (scanPlanBinaryUint32ToTextScanner) Scan(src []byte, dst any) error { return s.ScanText(Text{}) } + if len(src) != 4 { + return fmt.Errorf("invalid length for uint32: %v", len(src)) + } + n := uint64(binary.BigEndian.Uint32(src)) return s.ScanText(Text{String: strconv.FormatUint(n, 10), Valid: true}) }