From d251c8e2357dedc56ea775b6d4443532929b321e Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Wed, 11 Sep 2024 09:23:00 -0700 Subject: [PATCH] Fix bit packing of bundle params (#192) Fix a fuzzbug introduced in #185 where we missed updating a mask after also updating a constant indicating that the bit was no longer used. This PR fixes the bug by using the appropriate constant when masking, and also removing some additional functions that were missed in #185. co-authored-by: Chris Fallin --- src/ion/data_structures.rs | 12 +----------- src/ion/merge.rs | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/ion/data_structures.rs b/src/ion/data_structures.rs index b62cb2c0..93ce3917 100644 --- a/src/ion/data_structures.rs +++ b/src/ion/data_structures.rs @@ -239,11 +239,6 @@ impl LiveBundle { self.spill_weight_and_props & (1 << 29) != 0 } - #[inline(always)] - pub fn cached_stack(&self) -> bool { - self.spill_weight_and_props & (1 << 28) != 0 - } - #[inline(always)] pub fn set_cached_fixed(&mut self) { self.spill_weight_and_props |= 1 << 30; @@ -254,14 +249,9 @@ impl LiveBundle { self.spill_weight_and_props |= 1 << 29; } - #[inline(always)] - pub fn set_cached_stack(&mut self) { - self.spill_weight_and_props |= 1 << 28; - } - #[inline(always)] pub fn cached_spill_weight(&self) -> u32 { - self.spill_weight_and_props & ((1 << 28) - 1) + self.spill_weight_and_props & BUNDLE_MAX_SPILL_WEIGHT } } diff --git a/src/ion/merge.rs b/src/ion/merge.rs index 04afaf2f..380dde9e 100644 --- a/src/ion/merge.rs +++ b/src/ion/merge.rs @@ -110,11 +110,7 @@ impl<'a, F: Function> Env<'a, F> { } // Check for a requirements conflict. - if self.bundles[from].cached_stack() - || self.bundles[from].cached_fixed() - || self.bundles[to].cached_stack() - || self.bundles[to].cached_fixed() - { + if self.bundles[from].cached_fixed() || self.bundles[to].cached_fixed() { if self.merge_bundle_requirements(from, to).is_err() { trace!(" -> conflicting requirements; aborting merge"); return false; @@ -155,9 +151,6 @@ impl<'a, F: Function> Env<'a, F> { } self.bundles[to].ranges = list; - if self.bundles[from].cached_stack() { - self.bundles[to].set_cached_stack(); - } if self.bundles[from].cached_fixed() { self.bundles[to].set_cached_fixed(); } @@ -224,9 +217,6 @@ impl<'a, F: Function> Env<'a, F> { *to_range = to_range.join(from_range); } - if self.bundles[from].cached_stack() { - self.bundles[to].set_cached_stack(); - } if self.bundles[from].cached_fixed() { self.bundles[to].set_cached_fixed(); }