@@ -155,10 +155,10 @@ func (c *Conn) handleStmtExecute(data []byte) (*mysql.Result, error) {
155
155
pos += paramNum << 1
156
156
157
157
paramValues = data [pos :]
158
- }
159
158
160
- if err := c .bindStmtArgs (s , nullBitmaps , paramTypes , paramValues ); err != nil {
161
- return nil , errors .Trace (err )
159
+ if err := c .bindStmtArgs (s , nullBitmaps , paramTypes , paramValues ); err != nil {
160
+ return nil , errors .Trace (err )
161
+ }
162
162
}
163
163
}
164
164
@@ -176,6 +176,14 @@ func (c *Conn) handleStmtExecute(data []byte) (*mysql.Result, error) {
176
176
func (c * Conn ) bindStmtArgs (s * Stmt , nullBitmap , paramTypes , paramValues []byte ) error {
177
177
args := s .Args
178
178
179
+ // Every param should have a type-and-flag of 2 bytes
180
+ // 0xfe80 == Type 0xfe and Flag 0x80
181
+ // The flag only has one bit and that indicates if it is unsigned or not.
182
+ // Types are 1 byte, but might grow into the 7 unused bits in the future.
183
+ if len (paramTypes )/ 2 != s .Params {
184
+ return mysql .ErrMalformPacket
185
+ }
186
+
179
187
pos := 0
180
188
181
189
var v []byte
@@ -190,7 +198,7 @@ func (c *Conn) bindStmtArgs(s *Stmt, nullBitmap, paramTypes, paramValues []byte)
190
198
}
191
199
192
200
tp := paramTypes [i << 1 ]
193
- isUnsigned := (paramTypes [(i << 1 )+ 1 ] & 0x80 ) > 0
201
+ isUnsigned := (paramTypes [(i << 1 )+ 1 ] & mysql . PARAM_UNSIGNED ) > 0
194
202
195
203
switch tp {
196
204
case mysql .MYSQL_TYPE_NULL :
0 commit comments