Skip to content

Commit

Permalink
add byte length check to uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp committed Aug 23, 2024
1 parent b197994 commit 73bbced
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pgtype/uint32.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down

0 comments on commit 73bbced

Please sign in to comment.