Skip to content

Commit

Permalink
fix: tests/OOM_alloc2.xls: if first column is too large, set to 0 to …
Browse files Browse the repository at this point in the history
…prevent OOM allocation due to overflow
  • Loading branch information
sftse committed Aug 30, 2024
1 parent 6a9479a commit 5026788
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/xls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ fn parse_label_sst(r: &[u8], strings: &[String]) -> Result<Option<Cell<Data>>, X
}

fn parse_dimensions(r: &[u8]) -> Result<Dimensions, XlsError> {
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,
Expand All @@ -846,6 +846,12 @@ fn parse_dimensions(r: &[u8]) -> Result<Dimensions, XlsError> {
});
}
};
// 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),
Expand Down

0 comments on commit 5026788

Please sign in to comment.