Repository navigation
Commit 65aad0f
fix(mcp): an integer argument outside int range takes the default
Distilled from #1245 by Andrew Hundt (d030c8f).
cbm_mcp_get_int_arg read integer arguments with yyjson_is_int and
yyjson_get_int, and the int cast inside get_int truncates. A client
sending {"limit": 4294967297} -- 2^32 + 1 -- got back 1: the low word of
the value, silently, as a bound. The same read serves limit and offset
on the query tools, so an oversized page request became a page of one.
The argument is now read as a 64-bit signed or unsigned integer and only
accepted if it fits in int; anything outside the range takes the
caller's default, exactly as a non-integer does. In-range values and
non-integer JSON behave as before. One difference from the upstream
hunk: the unsigned comparison casts INT_MAX explicitly rather than
relying on the implicit conversion.
RED before the fix:
mcp_get_int_arg FAIL tests/test_mcp.c:1777: val == 1, expected 17 == 17
The test now covers 2^32 + 1, its negative, INT_MAX + 1 and INT64_MIN
each returning a distinct default, and INT_MAX, INT_MIN and -7 passing
through unchanged.
GREEN after: mcp 318 passed, 4 skipped (the Windows-only skips);
mcp cli daemon_application 692 passed, 0 failed.
Co-authored-by: Andrew Hundt <ATHundt@gmail.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent 66d9c2b commit 65aad0f
2 files changed
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1584 | 1584 | | |
1585 | 1585 | | |
1586 | 1586 | | |
1587 | | - | |
1588 | | - | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
1589 | 1600 | | |
1590 | 1601 | | |
1591 | 1602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1771 | 1771 | | |
1772 | 1772 | | |
1773 | 1773 | | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
1774 | 1791 | | |
1775 | 1792 | | |
1776 | 1793 | | |
| |||
0 commit comments