5
5
"encoding/binary"
6
6
"encoding/hex"
7
7
"encoding/json"
8
+ "errors"
8
9
"fmt"
10
+ "math"
9
11
10
12
"github.com/jackc/pgx/v5/internal/pgio"
11
13
)
@@ -116,11 +118,17 @@ func (src *Bind) Encode(dst []byte) ([]byte, error) {
116
118
dst = append (dst , src .PreparedStatement ... )
117
119
dst = append (dst , 0 )
118
120
121
+ if len (src .ParameterFormatCodes ) > math .MaxUint16 {
122
+ return nil , errors .New ("too many parameter format codes" )
123
+ }
119
124
dst = pgio .AppendUint16 (dst , uint16 (len (src .ParameterFormatCodes )))
120
125
for _ , fc := range src .ParameterFormatCodes {
121
126
dst = pgio .AppendInt16 (dst , fc )
122
127
}
123
128
129
+ if len (src .Parameters ) > math .MaxUint16 {
130
+ return nil , errors .New ("too many parameters" )
131
+ }
124
132
dst = pgio .AppendUint16 (dst , uint16 (len (src .Parameters )))
125
133
for _ , p := range src .Parameters {
126
134
if p == nil {
@@ -132,6 +140,9 @@ func (src *Bind) Encode(dst []byte) ([]byte, error) {
132
140
dst = append (dst , p ... )
133
141
}
134
142
143
+ if len (src .ResultFormatCodes ) > math .MaxUint16 {
144
+ return nil , errors .New ("too many result format codes" )
145
+ }
135
146
dst = pgio .AppendUint16 (dst , uint16 (len (src .ResultFormatCodes )))
136
147
for _ , fc := range src .ResultFormatCodes {
137
148
dst = pgio .AppendInt16 (dst , fc )
0 commit comments