More OOM fixes#525
Conversation
…prevent OOM allocation due to overflow
…e, otherwise this will crash
There was a problem hiding this comment.
Pull Request Overview
This PR adds handling for an additional OOM-related test file and tightens parsing functions to avoid over-allocation and out-of-bounds dimensions.
- Extended the existing
test_oom_allocationto coverOOM_alloc2.xlsand verify the worksheet name. - Refactored
parse_stringto use a dynamic header length, early-return empty strings for zero-length records, and updated decoding offsets. - Updated
parse_dimensionsto clamp invalid column ranges and added a new unit test forparse_string.
Comments suppressed due to low confidence (2)
src/xls.rs:875
- Add a unit test for
parse_dimensionscovering the branch wherecf > 0xFForcl < cf, to confirm thatcfis correctly reset to 0.
if 0xFF < cf || cl < cf {
src/xls.rs:792
- Introduce a unit test for the special-case in
parse_stringwhere a two-byte zero-length record returnsOk(String::new()), ensuring the early-return branch behaves as intended.
if 2 == r.len() && read_u16(r) == 0 {
|
LGTM. I ran Copilot review since it sometimes picks up something useful. In this case I'm not sure the comment is correct. I'm happy to merge as-is unless you want to make a change.
That would require a call by @tafia. I'll review it in the context of the Xlsx file when I get to that part of the docs. Let's leave it in place for now. |
|
Named constants make sense to me if there really is a meaningful name to attach to it or if it is used repeatedly. In this case it really is a magic constant extracted from the spec, with no obvious indication why it may not be larger than 0xFF. Referencing the spec is about as meaningful as it can get. Good to merge. |
|
Merged. Thanks. |
This is another batch of commits from #463.
This adds another test case that OOM allocates.
I rechecked the work and noticed that the
fn parse_dimensionsis in some sense superfluous. This fixes the function as-is, but I don't see what the function is even doing, or if there are any features that depend on it. It only is used to reserve space on theVecholding the cells, and from basic testing always overallocates, sometimes by quite a bit.If no features depend on parsing the dimensions it might be sensible to remove, but we can also merge as-is.