Skip to content

Commit 81ba295

Browse files
authored
Merge branch 'master' into feature/add-support-openjph-fuzzer-targets
2 parents c83a677 + bf7a166 commit 81ba295

File tree

22 files changed

+53
-11
lines changed

22 files changed

+53
-11
lines changed

projects/apache-poi/src/main/java/org/apache/poi/POIFileHandlerFuzzer.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.apache.poi;
1818

19+
import java.awt.AWTError;
1920
import java.awt.geom.IllegalPathStateException;
2021
import java.io.ByteArrayInputStream;
2122
import java.io.IOException;
@@ -50,6 +51,7 @@
5051
import org.apache.poi.stress.XWPFFileHandler;
5152
import org.apache.poi.util.DocumentFormatException;
5253
import org.apache.poi.util.RecordFormatException;
54+
import org.apache.poi.xssf.binary.XSSFBParseException;
5355
import org.apache.xmlbeans.XmlException;
5456
import org.junit.platform.commons.util.ExceptionUtils;
5557
import org.opentest4j.AssertionFailedError;
@@ -99,13 +101,18 @@ public static void fuzzerTestOneInput(byte[] input) throws Exception {
99101
IllegalArgumentException | IllegalStateException | IndexOutOfBoundsException | NoSuchElementException |
100102
UnsupportedOperationException | NegativeArraySizeException | BufferUnderflowException |
101103
ChunkNotFoundException | RecordInputStream.LeftoverDataException | RecordFormatException |
102-
OpenXML4JException | OpenXML4JRuntimeException | DocumentFormatException |
104+
OpenXML4JException | OpenXML4JRuntimeException | DocumentFormatException | XSSFBParseException |
103105
// some FileHandlers perform checks via assertions, so we expect this type of exception as well
104106
AssertionFailedError | TestAbortedException |
105107
NotImplementedException | FormulaParseException | IllegalPathStateException
106108
e) {
107109
// expected here
108-
} catch (java.lang.InternalError e) {
110+
} catch (AWTError e) {
111+
// POI cannot fix it if there is no DISPLAY
112+
if (!ExceptionUtils.readStackTrace(e).contains("Can't connect to X11 window server")) {
113+
throw e;
114+
}
115+
} catch (InternalError e) {
109116
// POI cannot fix it if the font-system is not fully installed, so let's ignore
110117
// this for fuzzing
111118
if (!ExceptionUtils.readStackTrace(e).contains("Fontconfig head is null")) {

projects/apache-poi/src/main/java/org/apache/poi/POIHSLFFuzzer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public static void fuzzerTestOneInput(byte[] input) {
4343
slides.write(NullOutputStream.INSTANCE);
4444
} catch (IOException | IllegalArgumentException | RecordFormatException |
4545
IllegalStateException | HSLFException | IndexOutOfBoundsException |
46-
BufferUnderflowException | POIXMLException | NoSuchElementException e) {
46+
BufferUnderflowException | POIXMLException | NoSuchElementException |
47+
NegativeArraySizeException e) {
4748
// expected here
4849
}
4950

projects/binutils/fuzz_addr2line.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
2121
int
2222
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2323
{
24+
if (size > 16384)
25+
return 0;
2426
char filename[256];
2527
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
2628
FILE *fp = fopen(filename, "wb");

projects/binutils/fuzz_as.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ xatexit (void (*fn) (void) ATTRIBUTE_UNUSED)
3232

3333
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
3434
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
35+
if (size > 1024)
36+
return 0;
3537
char filename[256];
3638
sprintf(filename, "/tmp/libfuzzer-%d.s", getpid());
3739
FILE *fp = fopen(filename, "wb");

projects/binutils/fuzz_bfd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static int bufferToFile(char * name, const uint8_t *Data, size_t Size) {
3939
char *target = NULL;
4040

4141
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
42+
if (Size > 16384)
43+
return 0;
4244
char tmpfilename[32];
4345

4446
if (bfd_init() != BFD_INIT_MAGIC)

projects/binutils/fuzz_bfd_ext.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ static int bufferToFile(char *name, const uint8_t *Data, size_t Size) {
4242
}
4343

4444
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
45+
if (Size > 16384)
46+
return 0;
4547
char tmpfilename[32];
4648

4749
if (bfd_init() != BFD_INIT_MAGIC)

projects/binutils/fuzz_dlltool.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
6060
int
6161
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
6262
{
63-
if (size < 512) {
63+
if (size < 512 || size > 16384)
6464
return 0;
65-
}
6665

6766
/* def file */
6867
char filename[256];

projects/binutils/fuzz_dwarf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
2020
int
2121
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2222
{
23+
if (size > 16384)
24+
return 0;
2325
char filename[256];
2426
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
2527
FILE *fp = fopen(filename, "wb");

projects/binutils/fuzz_nm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
2121
int
2222
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
2323
{
24+
if (size > 16384)
25+
return 0;
2426
char filename[256];
2527
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
2628
FILE *fp = fopen(filename, "wb");

projects/binutils/fuzz_objcopy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ init_objcopy_global_state() {
9494
int
9595
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
9696
{
97+
if (size > 16384)
98+
return 0;
9799
char filename[256];
98100
sprintf(filename, "/tmp/libfuzzer.%d", getpid());
99101
FILE *fp = fopen(filename, "wb");

0 commit comments

Comments
 (0)