forked from 1b-agent/opencadstudio-upstream
fix(io): cap line reads on the serve and MCP transports
Bug: The --serve automation loop (stdin/socket) and the MCP stdio loop read input with unbounded read_line/lines. A single line over 64 MiB - a huge paste or a hostile client - grows the buffer until the allocator aborts, the same class of failure as the HTTP path, on the non-HTTP transports. Reproduce: 1. Start --serve on a socket (or the MCP server on stdio). 2. Send one 65 MiB line with no terminating newline anywhere in it. 3. Before: RSS grows to the full line, then "memory allocation failed" (or a multi-second stall while the line is copied). 4. After: the read fails at the cap and the existing EOF arm closes the connection/stdio promptly. Fix: New shared src/io/line_read.rs module: lines_capped(reader, 64 MiB) yields Err for an over-cap line, which the serve and MCP loops already treat as EOF/close. rest.rs was refactored onto the same helpers so the cap logic lives in one place. A regression test streams a 65 MiB line at the serve socket and asserts the connection ends without a response.
This commit is contained in:
1 parent
6c3c266475
commit
be8a7b95c4
5 files changed
+197
-49
No files matched your search
@@ -20,6 +20,7 @@ pub mod stl;
|
||||
pub mod xref;
|
||||
pub mod xref_model;
|
||||
pub mod linetypes;
|
||||
pub mod line_read;
|
||||
pub mod patterns;
|
||||
pub mod update_check;
|
||||
pub mod paper_catalog;
|
||||
|
||||
Reference in new issue
Block a user