* claim: #1783 * FreeCAD/Rhino import: decode caps with room for detailed parts (#1783) cadmpeg decoded FreeCAD and Rhino files under its service profile, whose million collection items and 2.56e8 work units a detailed part (a sprocket, a threaded rod, a part with a few hundred faces) runs past: the import was refused with "resource limit on CollectionItems: BudgetExceeded". Allow 8 million items and 2e9 work units, half of cadmpeg's desktop profile; the input-size cap stays SolidCraft's STEP limit and every other cap stays at the service profile's. decoding_is_capped checks the two raised caps (and that they stay below the desktop profile's) and that every other cap is still the service one. Fixes #1783
This commit is contained in:
1 parent
d78494e016
commit
1d9bdb1ca3
2 files changed
+24
-3
No files matched your search
@@ -57,7 +57,15 @@ mod convert {
|
||||
pub(super) fn policy() -> DecodePolicy {
|
||||
DecodePolicy {
|
||||
mode: DecodeMode::Salvage,
|
||||
limits: ResourceLimits { max_input_bytes: crate::MAX_STEP_BYTES as u64, ..ResourceLimits::service() },
|
||||
// Service caps on size, with room for the work a large assembly's decode takes and
|
||||
// for the collections of a detailed part (a part with thousands of faces holds more
|
||||
// than the service profile's million items).
|
||||
limits: ResourceLimits {
|
||||
max_input_bytes: crate::MAX_STEP_BYTES as u64,
|
||||
max_work_units: 2_000_000_000,
|
||||
max_collection_items: 8_000_000,
|
||||
..ResourceLimits::service()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,13 +100,26 @@ fn hostile_native_cad_never_panics() {
|
||||
}
|
||||
}
|
||||
|
||||
/// cadmpeg decodes under its tight `service` caps, with our STEP size limit on the input.
|
||||
/// cadmpeg decodes under its tight `service` caps, with our STEP size limit on the input and
|
||||
/// room for the work a large assembly takes (2·10⁹ units, half its desktop profile's) and the
|
||||
/// collections of a detailed part (8·10⁶ items, half its desktop profile's).
|
||||
#[test]
|
||||
fn decoding_is_capped() {
|
||||
let limits = convert::policy().limits;
|
||||
let service = cadmpeg_core::decode::ResourceLimits::service();
|
||||
let desktop = cadmpeg_core::decode::ResourceLimits::desktop();
|
||||
assert_eq!(limits.max_input_bytes, crate::MAX_STEP_BYTES as u64);
|
||||
assert_eq!(cadmpeg_core::decode::ResourceLimits { max_input_bytes: service.max_input_bytes, ..limits }, service);
|
||||
assert_eq!(limits.max_work_units, 2_000_000_000);
|
||||
assert!(limits.max_work_units < desktop.max_work_units);
|
||||
assert_eq!(limits.max_collection_items, 8_000_000);
|
||||
assert!(limits.max_collection_items < desktop.max_collection_items);
|
||||
let same = cadmpeg_core::decode::ResourceLimits {
|
||||
max_input_bytes: service.max_input_bytes,
|
||||
max_work_units: service.max_work_units,
|
||||
max_collection_items: service.max_collection_items,
|
||||
..limits
|
||||
};
|
||||
assert_eq!(same, service);
|
||||
}
|
||||
|
||||
/// A FreeCAD archive whose Document.xml inflates past the per-entry cap (a ZIP bomb, 300 MB of
|
||||
|
||||
Reference in new issue
Block a user