Skip to content

Commit

Permalink
Raise when message exceeds maximum size, closes #711
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed Oct 23, 2024
1 parent 731a1ae commit 5078a2c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/postgrex/messages.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ defmodule Postgrex.Messages do
{first, data} = encode(msg)
size = IO.iodata_length(data) + 4

if size > 0xFFFFFFFF do
raise ArgumentError, "payload size #{size} exceeds maximum size of #{0xFFFFFFFF}"
end

if first do
[first, <<size::int32()>>, data]
else
Expand Down

0 comments on commit 5078a2c

Please sign in to comment.