Commit b38de06
Cap server-declared num_params in StmtResponse decode
Every other count-bearing field decoded from a response already
enforces an upper bound (_MAX_COLUMN_COUNT, _MAX_FILE_COUNT,
_MAX_NODE_COUNT in responses.py, _MAX_PARAM_COUNT in tuples.py).
StmtResponse.num_params was the outlier, accepting any uint64 the
server put on the wire.
Reuse the encoder cap from tuples.py so the client and server-side
declarations stay in lockstep. A server declaring more parameters
than a well-formed prepared statement could ever bind is either
malicious or corrupt; surface as a clean DecodeError at the wire
boundary instead of passing an unchecked value upward.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e522b05 commit b38de06
2 files changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
270 | 280 | | |
271 | 281 | | |
272 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
224 | 241 | | |
225 | 242 | | |
226 | 243 | | |
| |||
0 commit comments