forked from 1b-agent/opencadstudio-upstream
Bound typed counts and values that could crash the editor
- ARRAYRECT, ARRAYPOLAR, ARRAYPATH, ARRAY3D and COPY Array reject item counts above 100,000 (checked as a product of every dimension) and keep the prompt open. Unbounded counts allocated one transform per item and aborted on allocation failure. Stored defaults are clamped as well. - EXPLODE leaves a MINSERT above the same limit intact instead of materializing every cell. - Typed lengths and angles reject non-finite values and magnitudes above 1e15; SCALE rejects a non-finite factor. - Zero-radius FILLET compares candidate intersections with total_cmp and rejects non-finite results; partial_cmp().unwrap() panicked on NaN. - SOLID falls back to a minimal kernel tolerance when its corners' extent overflows, since Tolerance::new panics on infinity. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
38aa2ee34d
commit
a3d65e2fc8
7 files changed
+223
-15
No files matched your search
@@ -199,6 +199,9 @@ impl CadCommand for CopyCommand {
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
if self.awaiting_count {
|
||||
if let Ok(n) = text.trim().parse::<usize>() {
|
||||
if !super::array::array_items_within_limit(&[n as u64]) {
|
||||
return Some(super::array::array_limit_error());
|
||||
}
|
||||
if n >= 2 {
|
||||
self.array_count = Some(n);
|
||||
}
|
||||
@@ -277,6 +280,18 @@ mod tests {
|
||||
cmd.options().into_iter().map(|o| o.keyword).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn array_count_above_the_item_limit_is_rejected() {
|
||||
let mut cmd = CopyCommand::new(vec![Handle::new(1)], vec![]);
|
||||
cmd.awaiting_count = true;
|
||||
assert!(matches!(
|
||||
cmd.on_text_input("18446744073709551615"),
|
||||
Some(CmdResult::ReportError(_))
|
||||
));
|
||||
assert!(cmd.awaiting_count, "the count prompt stays up");
|
||||
assert_eq!(cmd.array_count, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mode_single_exits_after_one_copy() {
|
||||
let mut cmd = CopyCommand::new(vec![Handle::new(1)], vec![]);
|
||||
|
||||
Reference in new issue
Block a user