Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apache POI: install libraries for awt and adjust xmx #11006

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions projects/apache-poi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ WORKDIR ${SRC}
#
RUN git clone --depth 1 https://github.com/apache/poi.git

# install packages required for font-handling and other code in java.awt.*
RUN apt-get install -y libxext6 libx11-6 libxrender1 libxtst6 libxi6 libxcb1 libxau6 libxdmcp6

ADD pom.xml build.sh ${SRC}/
ADD src/ ${SRC}/src/
WORKDIR ${SRC}/poi
16 changes: 13 additions & 3 deletions projects/apache-poi/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ ALL_JARS=""
LIBRARY_NAME="poi"
GRADLE_FLAGS="-x javadoc -x test -Dfile.encoding=UTF-8 -Porg.gradle.java.installations.fromEnv=JAVA_HOME_8,JAVA_HOME_11 --console=plain"

echo Copy libraries for java.awt in place
ls /usr/lib/x86_64-linux-gnu/
cp /usr/lib/x86_64-linux-gnu/libXext.so.6* \
/usr/lib/x86_64-linux-gnu/libX11.so.6* \
/usr/lib/x86_64-linux-gnu/libXrender.so.1* \
/usr/lib/x86_64-linux-gnu/libXtst.so.6* \
/usr/lib/x86_64-linux-gnu/libXi.so.6* \
/usr/lib/x86_64-linux-gnu/libxcb.so.1* \
/usr/lib/x86_64-linux-gnu/libXau.so.6* \
/usr/lib/x86_64-linux-gnu/libXdmcp.so.6* \
${OUT}/

echo Main Java
${JAVA_HOME}/bin/java -version

Expand Down Expand Up @@ -71,8 +83,6 @@ pushd "${SRC}"
ALL_JARS="${ALL_JARS} ${LIBRARY_NAME}-fuzzer-${CURRENT_VERSION}.jar"
popd



# The classpath at build-time includes the project jars in $OUT as well as the
# Jazzer API.
BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH
Expand Down Expand Up @@ -108,7 +118,7 @@ LD_LIBRARY_PATH=\"\$JVM_LD_LIBRARY_PATH\":\$this_dir \
--cp=${RUNTIME_CLASSPATH} \
--instrumentation_includes=org.apache.poi.**:org.apache.xmlbeans.** \
--target_class=${fuzzer_classname} \
--jvm_args=\"-Xmx2048m\" \
--jvm_args=\"-Xmx1024m\" \
\$@" > $OUT/${fuzzer_basename}
chmod u+x $OUT/${fuzzer_basename}
done
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@ public static void fuzzAny(byte[] input) {
public static void checkExtractor(byte[] input) {
try (POITextExtractor extractor = ExtractorFactory.createExtractor(new ByteArrayInputStream(input))) {
checkExtractor(extractor);
} catch (UnsatisfiedLinkError e) {
// only allow one missing library related to Font/Color-handling
// we cannot install additional libraries in oss-fuzz images currently
// see https://github.com/google/oss-fuzz/issues/7380
if (!e.getMessage().contains("libawt_xawt.so")) {
throw e;
}
} catch (IOException | POIXMLException | IllegalArgumentException | RecordFormatException |
IndexOutOfBoundsException | HSLFException | RecordInputStream.LeftoverDataException |
NoSuchElementException | IllegalStateException | ArithmeticException |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ public static void fuzzerTestOneInput(byte[] input) {
new POIFSFileSystem(new ByteArrayInputStream(input)).getRoot())) {
POIFuzzer.checkExtractor(extractor);
}
} catch (UnsatisfiedLinkError e) {
// only allow one missing library related to Font-handling
// we cannot install JDK font packages in oss-fuzz images currently
// see https://github.com/google/oss-fuzz/issues/7380
if (!e.getMessage().contains("libawt_xawt.so")) {
throw e;
}
} catch (IOException | IllegalArgumentException | RecordFormatException | IllegalStateException |
IndexOutOfBoundsException | RecordInputStream.LeftoverDataException |
BufferUnderflowException | UnsupportedOperationException | NoSuchElementException |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ public static void fuzzerTestOneInput(byte[] input) {
try (SXSSFWorkbook swb = new SXSSFWorkbook(wb)) {
swb.write(NullOutputStream.INSTANCE);
}
} catch (NoClassDefFoundError e) {
// only allow some missing classes related to Font-handling
// we cannot install JDK font packages in oss-fuzz images currently
// see https://github.com/google/oss-fuzz/issues/7380
if (!e.getMessage().contains("java.awt.Font") &&
!e.getMessage().contains("java.awt.Toolkit") &&
!e.getMessage().contains("sun.awt.X11FontManager")) {
throw e;
}
} catch (IOException | POIXMLException | RecordFormatException | IllegalStateException |
OpenXML4JRuntimeException | IllegalArgumentException | IndexOutOfBoundsException e) {
// expected here
Expand All @@ -54,15 +45,6 @@ public static void fuzzerTestOneInput(byte[] input) {
try (XSSFEventBasedExcelExtractor extractor = new XSSFEventBasedExcelExtractor(pkg)) {
POIFuzzer.checkExtractor(extractor);
}
} catch (NoClassDefFoundError e) {
// only allow some missing classes related to Font-handling
// we cannot install JDK font packages in oss-fuzz images currently
// see https://github.com/google/oss-fuzz/issues/7380
if (!e.getMessage().contains("java.awt.Font") &&
!e.getMessage().contains("java.awt.Toolkit") &&
!e.getMessage().contains("sun.awt.X11FontManager")) {
throw e;
}
} catch (IOException | XmlException | OpenXML4JException | POIXMLException | RecordFormatException |
IllegalStateException | IllegalArgumentException | IndexOutOfBoundsException e) {
// expected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ public static void fuzzerTestOneInput(byte[] input) {
OPCPackage p = OPCPackage.open(in);
XLSX2CSV xlsx2csv = new XLSX2CSV(p, NullPrintStream.INSTANCE, 5);
xlsx2csv.process();
} catch (UnsatisfiedLinkError e) {
// only allow one missing library related to Font/Color-handling
// we cannot install additional libraries in oss-fuzz images currently
// see https://github.com/google/oss-fuzz/issues/7380
if (!e.getMessage().contains("libawt_xawt.so")) {
throw e;
}
} catch (IOException | OpenXML4JException | SAXException |
POIXMLException | RecordFormatException |
IllegalStateException | IllegalArgumentException |
Expand Down
Loading