Bug 66425: Avoid Exceptions found via oss-fuzz

We try to avoid throwing ConcurrentModificationException,
but it was possible to trigger one here with a specially
crafted input-file

Should fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62861

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-10-07 22:12:50 +00:00
parent 5cd4fa5488
commit e43c1bc911
6 changed files with 7 additions and 1 deletions

View File

@ -73,7 +73,10 @@ public final class CustomViewSettingsRecordAggregate extends RecordAggregate {
return; return;
} }
rv.visitRecord(_begin); rv.visitRecord(_begin);
for (RecordBase rb : _recs) {
// need to copy list to avoid ConcurrentModificationException
// as there are cases where the visitor modifies the list itself
for (RecordBase rb : new ArrayList<>(_recs)) {
if (rb instanceof RecordAggregate) { if (rb instanceof RecordAggregate) {
((RecordAggregate) rb).visitContainedRecords(rv); ((RecordAggregate) rb).visitContainedRecords(rv);
} else { } else {

View File

@ -56,6 +56,7 @@ class TestBiffDrawingToXml extends BaseTestIteratingXLS {
excludes.put("protected_66115.xls", EncryptedDocumentException.class); excludes.put("protected_66115.xls", EncryptedDocumentException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5285517825277952.xls", IllegalArgumentException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5436547081830400.xls", IllegalArgumentException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5436547081830400.xls", IllegalArgumentException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class);
return excludes; return excludes;
} }

View File

@ -43,6 +43,7 @@ class TestBiffViewer extends BaseTestIteratingXLS {
excludes.put("poi-fuzz.xls", RecordFormatException.class); excludes.put("poi-fuzz.xls", RecordFormatException.class);
excludes.put("protected_66115.xls", RecordFormatException.class); excludes.put("protected_66115.xls", RecordFormatException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", IllegalStateException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", IllegalStateException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class);
return excludes; return excludes;
} }

View File

@ -46,6 +46,7 @@ class TestRecordLister extends BaseTestIteratingXLS {
protected Map<String, Class<? extends Throwable>> getExcludes() { protected Map<String, Class<? extends Throwable>> getExcludes() {
Map<String, Class<? extends Throwable>> excludes = super.getExcludes(); Map<String, Class<? extends Throwable>> excludes = super.getExcludes();
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", RecordFormatException.class); excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5786329142919168.xls", RecordFormatException.class);
excludes.put("clusterfuzz-testcase-minimized-POIHSSFFuzzer-5889658057523200.xls", IndexOutOfBoundsException.class);
return excludes; return excludes;
} }

Binary file not shown.