diff --git a/src/xls.rs b/src/xls.rs index ce42fe7..1cf126c 100644 --- a/src/xls.rs +++ b/src/xls.rs @@ -825,7 +825,7 @@ fn parse_label_sst(r: &[u8], strings: &[String]) -> Result>, X } fn parse_dimensions(r: &[u8]) -> Result { - let (rf, rl, cf, cl) = match r.len() { + let (rf, rl, mut cf, cl) = match r.len() { 10 => ( read_u16(&r[0..2]) as u32, read_u16(&r[2..4]) as u32, @@ -846,6 +846,12 @@ fn parse_dimensions(r: &[u8]) -> Result { }); } }; + // 2.5.53 ColU must be <= 0xFF, if larger, reasonable to assume + // starts at 0 + // tests/OOM_alloc2.xls + if 0xFF < cf || cl < cf { + cf = 0; + } if 1 <= rl && 1 <= cl { Ok(Dimensions { start: (rf, cf),