mirror of https://github.com/google/oss-fuzz.git
libass: migrate to upstream changes (#8552)
Fixes: https://github.com/google/oss-fuzz/issues/8526
This commit is contained in:
parent
7cd6569f8a
commit
bd848023c1
|
@ -21,4 +21,4 @@ RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-conf
|
|||
RUN git clone --depth 1 https://github.com/libass/libass.git
|
||||
RUN git clone --depth 1 https://github.com/harfbuzz/harfbuzz.git
|
||||
|
||||
COPY build.sh libass_fuzzer.cc *.dict *.options $SRC/
|
||||
COPY build.sh *.options $SRC/
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
"0x"
|
||||
"\\1a"
|
||||
"\\2a"
|
||||
"\\2c"
|
||||
"\\3a"
|
||||
"\\3c"
|
||||
"\\4a"
|
||||
"\\4c"
|
||||
"\\a"
|
||||
"\\alpha"
|
||||
"\\an"
|
||||
"Arial"
|
||||
"\\b"
|
||||
"Banner;"
|
||||
"\\be"
|
||||
"\\blur"
|
||||
"\\bord"
|
||||
"\\c"
|
||||
"CFF"
|
||||
"CID Type 1"
|
||||
"\\clip"
|
||||
"clip"
|
||||
"Courier"
|
||||
"Courier New"
|
||||
"Default"
|
||||
"Dialogue:"
|
||||
"[Events]"
|
||||
"\\fade"
|
||||
"\\fax"
|
||||
"\\fay"
|
||||
"\\fe"
|
||||
"\\fn"
|
||||
"fontname:"
|
||||
"[Fonts]"
|
||||
"Format:"
|
||||
"\\frx"
|
||||
"\\fry"
|
||||
"\\frz"
|
||||
"\\fs"
|
||||
"\\fsc"
|
||||
"\\fscx"
|
||||
"\\fscy"
|
||||
"\\fsp"
|
||||
"&h"
|
||||
"Helvetica"
|
||||
"\\i"
|
||||
"\\iclip"
|
||||
"iclip"
|
||||
"\\k"
|
||||
"Kerning:"
|
||||
"Kerning"
|
||||
"\\kf"
|
||||
"\\ko"
|
||||
"Language:"
|
||||
"monospace"
|
||||
"\\move"
|
||||
"move"
|
||||
"none"
|
||||
"\\org"
|
||||
"org"
|
||||
"OverrideStyle"
|
||||
"\\p"
|
||||
"p"
|
||||
"\\pbo"
|
||||
"pbo"
|
||||
"pc.240m"
|
||||
"pc.601"
|
||||
"pc.709"
|
||||
"pc.fcc"
|
||||
"PlayResX:"
|
||||
"PlayResX"
|
||||
"PlayResY:"
|
||||
"PlayResY"
|
||||
"\\pos"
|
||||
"pos"
|
||||
"\\q"
|
||||
"\\r"
|
||||
"\\s"
|
||||
"sans-serif"
|
||||
"ScaledBorderAndShadow:"
|
||||
"ScaledBorderAndShadow"
|
||||
"[Script Info]"
|
||||
"Scroll down;"
|
||||
"Scroll up;"
|
||||
"serif"
|
||||
"\\shad"
|
||||
"Style:"
|
||||
"\\t"
|
||||
"Text"
|
||||
"Timer:"
|
||||
"Timer"
|
||||
"Times"
|
||||
"Times New Roman"
|
||||
"tv.240m"
|
||||
"tv.601"
|
||||
"tv.709"
|
||||
"tv.fcc"
|
||||
"Type 1"
|
||||
"Type 42"
|
||||
"\\u"
|
||||
"UTF-8"
|
||||
"[V4 Styles]"
|
||||
"[V4+ Styles]"
|
||||
"WrapStyle:"
|
||||
"WrapStyle"
|
||||
"\\xbord"
|
||||
"\\xshad"
|
||||
"\\ybord"
|
||||
"YCbCr Matrix:"
|
||||
"YCbCr Matrix"
|
||||
"yes"
|
||||
"\\yshad"
|
|
@ -38,14 +38,9 @@ cd $SRC/libass
|
|||
|
||||
export PKG_CONFIG_PATH=/work/lib/pkgconfig
|
||||
./autogen.sh
|
||||
./configure --disable-asm
|
||||
make -j$(nproc)
|
||||
./configure FUZZ_CPPFLAGS="-DASS_FUZZMODE=2" --disable-asm --disable-shared --enable-fuzz
|
||||
make -j "$(nproc)" fuzz/fuzz_ossfuzz
|
||||
cp fuzz/fuzz_ossfuzz $OUT/libass_fuzzer
|
||||
cp fuzz/ass.dict $OUT/ass.dict
|
||||
|
||||
$CXX $CXXFLAGS -std=c++11 -I$SRC/libass \
|
||||
$SRC/libass_fuzzer.cc -o $OUT/libass_fuzzer \
|
||||
$LIB_FUZZING_ENGINE libass/.libs/libass.a \
|
||||
-Wl,-Bstatic \
|
||||
$(pkg-config --static --libs fontconfig freetype2 fribidi harfbuzz | sed 's/-lm //g') \
|
||||
-Wl,-Bdynamic
|
||||
|
||||
cp $SRC/*.dict $SRC/*.options $OUT/
|
||||
cp $SRC/*.options $OUT/
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
# Copyright 2021 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libass/ass.h>
|
||||
|
||||
static ASS_Library *ass_library;
|
||||
static ASS_Renderer *ass_renderer;
|
||||
|
||||
void msg_callback(int level, const char *fmt, va_list va, void *data) {
|
||||
}
|
||||
|
||||
static const int kFrameWidth = 1280;
|
||||
static const int kFrameHeight = 720;
|
||||
|
||||
struct init {
|
||||
init(int frame_w, int frame_h) {
|
||||
ass_library = ass_library_init();
|
||||
if (!ass_library) {
|
||||
printf("ass_library_init failed!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ass_set_message_cb(ass_library, msg_callback, NULL);
|
||||
|
||||
ass_renderer = ass_renderer_init(ass_library);
|
||||
if (!ass_renderer) {
|
||||
printf("ass_renderer_init failed!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ass_set_frame_size(ass_renderer, frame_w, frame_h);
|
||||
ass_set_fonts(ass_renderer, nullptr, "sans-serif",
|
||||
ASS_FONTPROVIDER_AUTODETECT, nullptr, 1);
|
||||
}
|
||||
|
||||
~init() {
|
||||
ass_renderer_done(ass_renderer);
|
||||
ass_library_done(ass_library);
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
static init initialized(kFrameWidth, kFrameHeight);
|
||||
|
||||
ASS_Track *track = ass_read_memory(ass_library, (char *)data, size, nullptr);
|
||||
if (!track) return 0;
|
||||
|
||||
for (int i = 0; i < track->n_events; ++i) {
|
||||
ASS_Event &ev = track->events[i];
|
||||
long long tm = ev.Start + ev.Duration / 2;
|
||||
ass_render_frame(ass_renderer, track, tm, nullptr);
|
||||
}
|
||||
ass_free_track(track);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue