Commit 5647b89
Enforce the parameter-count cap on encode_params_tuple
decode_params_tuple caps the decoded parameter count at
_MAX_PARAM_COUNT (100_000) as defense in depth; the encoder did not
mirror the same check for schema 1 (uint32 count). V0 has a 255 cap
from the 1-byte count field, but V1 is selected automatically whenever
the caller passes more than 255 parameters, so an accidental giant
params sequence burned an unbounded amount of allocation before the
64 MiB frame cap eventually fired with an opaque "buffer size exceeds
maximum" error.
Raise EncodeError with the same "exceeds maximum" shape the decoder
uses, placed after schema validation so the check fires uniformly
regardless of the short-circuit paths for empty params sequences.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0f2e583 commit 5647b89
2 files changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
0 commit comments