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
+28
-1
@@ -80,7 +80,14 @@ fn boundary_edges(points: &[[f64; 3]]) -> Vec<Edge> {
|
||||
}
|
||||
|
||||
fn kernel_tolerance(points: &[[f64; 3]]) -> f64 {
|
||||
cadkernel::space::coplanarity_tolerance(points).max(1.0e-12)
|
||||
let tolerance = cadkernel::space::coplanarity_tolerance(points);
|
||||
// Corners whose extent overflows f64 give an infinite tolerance, which
|
||||
// `Tolerance::new` rejects by panicking.
|
||||
if tolerance.is_finite() {
|
||||
tolerance.max(1.0e-12)
|
||||
} else {
|
||||
1.0e-12
|
||||
}
|
||||
}
|
||||
|
||||
fn extrusion_body(
|
||||
@@ -366,3 +373,23 @@ impl Transformable for Solid {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod overflow_tests {
|
||||
use super::*;
|
||||
use acadrust::types::Vector3;
|
||||
|
||||
/// Corners 1e308 apart overflow the coplanarity tolerance to infinity,
|
||||
/// which the kernel's `Tolerance::new` rejects by panicking.
|
||||
#[test]
|
||||
fn corners_with_overflowing_extent_do_not_panic() {
|
||||
let solid = Solid::new(
|
||||
Vector3::new(0.0, 0.0, 0.0),
|
||||
Vector3::new(1e308, 0.0, 0.0),
|
||||
Vector3::new(0.0, 1e308, 0.0),
|
||||
Vector3::new(1e308, 1e308, 0.0),
|
||||
);
|
||||
let _ = wcs_bounds(&solid);
|
||||
let _ = solid_geometry(&solid);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user