Skip to content

Commit

Permalink
Merge pull request #2114 from jennifersp/master
Browse files Browse the repository at this point in the history
add byte length check to uint32
  • Loading branch information
jackc committed Aug 26, 2024
2 parents 603f233 + 73bbced commit e9bd382
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 e9bd382

Please sign in to comment.