File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 77- Added ` Key ` implementation for the unit type ` () ` for easy storage of a single value
88- * Breaking:* Changed API for map ` fetch_all_items ` such that the ` Key ` is captured in ` MapItemIter ` .
99- Fixed some logic so queue can be used on a single page. (It's still recommended to use at least 2 pages for both the queue and the map)
10+ - Add some extra logic to catch more crc collisions
1011
1112## 4.0.3 18-06-25
1213
Original file line number Diff line number Diff line change @@ -97,15 +97,27 @@ impl ItemHeader {
9797 break ;
9898 }
9999
100- Ok ( Some ( Self {
100+ let header = Self {
101101 length : u16:: from_le_bytes ( header_slice[ Self :: LENGTH_FIELD ] . try_into ( ) . unwrap ( ) ) ,
102102 crc : {
103103 match u32:: from_le_bytes ( header_slice[ Self :: DATA_CRC_FIELD ] . try_into ( ) . unwrap ( ) ) {
104104 0 => None ,
105105 value => Some ( NonZeroU32 :: new ( value) . unwrap ( ) ) ,
106106 }
107107 } ,
108- } ) )
108+ } ;
109+
110+ if header. next_item_address :: < S > ( address) > end_address {
111+ // We have a header here that's claims it's larger than is possible
112+ // This is never written. So either it's a bug or there's a CRC collision
113+ // Let's assume the latter
114+ return Err ( Error :: Corrupted {
115+ #[ cfg( feature = "_test" ) ]
116+ backtrace : std:: backtrace:: Backtrace :: capture ( ) ,
117+ } ) ;
118+ }
119+
120+ Ok ( Some ( header) )
109121 }
110122
111123 pub async fn read_item < ' d , S : NorFlash > (
You can’t perform that action at this time.
0 commit comments