summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-03-11 10:13:33 +0000
committerLibravatar GitHub <noreply@github.com>2024-03-11 10:13:33 +0000
commitd115f9ebc4444c628269297f6d7ec427f7e5cf00 (patch)
tree242411bdcdf7c988700a52cc275eec20304db9c2 /vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go
parent[chore]: Bump github.com/gin-contrib/cors from 1.5.0 to 1.7.0 (#2745) (diff)
downloadgotosocial-d115f9ebc4444c628269297f6d7ec427f7e5cf00.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.5.3 to 5.5.5 (#2747)
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go b/vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go
index 2c4f38dfd..7d83579ff 100644
--- a/vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go
+++ b/vendor/github.com/jackc/pgx/v5/pgproto3/function_call.go
@@ -2,6 +2,8 @@ package pgproto3
import (
"encoding/binary"
+ "errors"
+ "math"
"github.com/jackc/pgx/v5/internal/pgio"
)
@@ -71,15 +73,21 @@ func (dst *FunctionCall) Decode(src []byte) error {
}
// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
-func (src *FunctionCall) Encode(dst []byte) []byte {
- dst = append(dst, 'F')
- sp := len(dst)
- dst = pgio.AppendUint32(dst, 0) // Unknown length, set it at the end
+func (src *FunctionCall) Encode(dst []byte) ([]byte, error) {
+ dst, sp := beginMessage(dst, 'F')
dst = pgio.AppendUint32(dst, src.Function)
+
+ if len(src.ArgFormatCodes) > math.MaxUint16 {
+ return nil, errors.New("too many arg format codes")
+ }
dst = pgio.AppendUint16(dst, uint16(len(src.ArgFormatCodes)))
for _, argFormatCode := range src.ArgFormatCodes {
dst = pgio.AppendUint16(dst, argFormatCode)
}
+
+ if len(src.Arguments) > math.MaxUint16 {
+ return nil, errors.New("too many arguments")
+ }
dst = pgio.AppendUint16(dst, uint16(len(src.Arguments)))
for _, argument := range src.Arguments {
if argument == nil {
@@ -90,6 +98,5 @@ func (src *FunctionCall) Encode(dst []byte) []byte {
}
}
dst = pgio.AppendUint16(dst, src.ResultFormatCode)
- pgio.SetInt32(dst[sp:], int32(len(dst[sp:])))
- return dst
+ return finishMessage(dst, sp)
}