mirror of https://github.com/google/oss-fuzz.git
[glib] GLib: integrate into build system (#1866)
* integrate into build system * remove options file * address review comment
This commit is contained in:
parent
e7c5398b61
commit
7f8c385c8f
|
@ -20,4 +20,4 @@ RUN apt-get update && apt-get install -y python3-pip
|
|||
RUN pip3 install -U meson ninja
|
||||
RUN git clone --depth 1 https://gitlab.gnome.org/GNOME/glib
|
||||
WORKDIR glib
|
||||
COPY build.sh fuzz* $SRC/
|
||||
COPY build.sh $SRC/
|
||||
|
|
|
@ -21,49 +21,18 @@ rm -rf $BUILD
|
|||
mkdir $BUILD
|
||||
|
||||
meson $BUILD \
|
||||
-Db_lundef=false \
|
||||
-Ddefault_library=static \
|
||||
-Dlibmount=false \
|
||||
-Dselinux=false
|
||||
|
||||
ninja -C $BUILD
|
||||
|
||||
$CC $CFLAGS -I. -Iglib -I$BUILD/glib -c $SRC/fuzz_bookmark.c
|
||||
$CXX $CXXFLAGS -lFuzzingEngine \
|
||||
fuzz_bookmark.o -o $OUT/fuzz_bookmark \
|
||||
$BUILD/glib/libglib-2.0.a $BUILD/glib/libcharset/libcharset.a
|
||||
cp $SRC/fuzz.options $OUT/fuzz_bookmark.options
|
||||
find glib/tests -type f -size -32k -name "*.xbel" \
|
||||
-exec zip -qju $OUT/fuzz_bookmark_seed_corpus.zip "{}" \;
|
||||
find $BUILD/fuzzing -maxdepth 1 -executable -type f -exec cp "{}" $OUT \;
|
||||
|
||||
$CC $CFLAGS -I. -Iglib -I$BUILD/glib -c $SRC/fuzz_key.c
|
||||
$CXX $CXXFLAGS -lFuzzingEngine \
|
||||
fuzz_key.o -o $OUT/fuzz_key \
|
||||
$BUILD/glib/libglib-2.0.a $BUILD/glib/libcharset/libcharset.a
|
||||
cp $SRC/fuzz.options $OUT/fuzz_key.options
|
||||
find gio/tests -type f -size -32k -name "*.desktop" \
|
||||
-exec zip -qju $OUT/fuzz_key_seed_corpus.zip "{}" \;
|
||||
find fuzzing -type f -name "*.dict" -exec cp "{}" $OUT \;
|
||||
|
||||
$CC $CFLAGS -I. -Iglib -I$BUILD/glib -c $SRC/fuzz_variant_text.c
|
||||
$CXX $CXXFLAGS -lFuzzingEngine \
|
||||
fuzz_variant_text.o -o $OUT/fuzz_variant_text \
|
||||
$BUILD/glib/libglib-2.0.a $BUILD/glib/libcharset/libcharset.a
|
||||
cp $SRC/fuzz.options $OUT/fuzz_variant_text.options
|
||||
cp $SRC/fuzz_variant_text.dict $OUT
|
||||
|
||||
$CC $CFLAGS -I. -Iglib -I$BUILD/glib -c $SRC/fuzz_variant_binary.c
|
||||
$CXX $CXXFLAGS -lFuzzingEngine \
|
||||
fuzz_variant_binary.o -o $OUT/fuzz_variant_binary \
|
||||
$BUILD/glib/libglib-2.0.a $BUILD/glib/libcharset/libcharset.a
|
||||
cp $SRC/fuzz.options $OUT/fuzz_variant_binary.options
|
||||
|
||||
$CC $CFLAGS -I. -Iglib -Igmodule -I$BUILD -I$BUILD/glib \
|
||||
-c $SRC/fuzz_dbus_message.c
|
||||
$CXX $CXXFLAGS -lFuzzingEngine \
|
||||
fuzz_dbus_message.o -o $OUT/fuzz_dbus_message \
|
||||
$BUILD/gio/libgio-2.0.a $BUILD/gmodule/libgmodule-2.0.a \
|
||||
$BUILD/gobject/libgobject-2.0.a $BUILD/glib/libglib-2.0.a \
|
||||
$BUILD/glib/libcharset/libcharset.a $BUILD/glib/pcre/libpcre.a \
|
||||
$BUILD/gio/xdgmime/libxdgmime.a $BUILD/gio/inotify/libinotify.a \
|
||||
$BUILD/subprojects/zlib*/libz.a $BUILD/subprojects/libffi/src/libffi.a \
|
||||
-Bstatic -lresolv
|
||||
cp $SRC/fuzz.options $OUT/fuzz_dbus_message.options
|
||||
for CORPUS in $(find fuzzing -type f -name "*.corpus"); do
|
||||
BASENAME=${CORPUS##*/}
|
||||
zip $OUT/${BASENAME%%.*}_seed_corpus.zip . -ws -r -i@$CORPUS
|
||||
done
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[libfuzzer]
|
||||
close_fd_mask = 2
|
|
@ -1,8 +0,0 @@
|
|||
#include "glib/glib.h"
|
||||
#include <stdint.h>
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
g_autoptr(GBookmarkFile) bookmarkfile = g_bookmark_file_new();
|
||||
g_bookmark_file_load_from_data(bookmarkfile, (const gchar*)data, size, NULL);
|
||||
return 0;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
#include "gio/gio.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static GDBusCapabilityFlags flags = G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING;
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
gssize bytes = g_dbus_message_bytes_needed((guchar*)data, size, NULL);
|
||||
if (bytes <= 0 || bytes > (100 << 20))
|
||||
return 0;
|
||||
|
||||
g_autoptr(GDBusMessage) msg =
|
||||
g_dbus_message_new_from_blob((guchar*)data, size, flags, NULL);
|
||||
if (!msg)
|
||||
return 0;
|
||||
|
||||
gsize msg_size;
|
||||
g_autofree guchar* blob = g_dbus_message_to_blob(msg, &msg_size, flags, NULL);
|
||||
return 0;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
#include "glib/glib.h"
|
||||
#include <stdint.h>
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
g_autoptr(GKeyFile) keyfile = g_key_file_new();
|
||||
g_key_file_load_from_data(keyfile, (const gchar*)data, size, 0, NULL);
|
||||
return 0;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include "glib/glib.h"
|
||||
#include <stdint.h>
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
g_autoptr(GVariant) variant = g_variant_new_from_data(
|
||||
G_VARIANT_TYPE_VARIANT, data, size, FALSE, NULL, NULL);
|
||||
if (!variant)
|
||||
return 0;
|
||||
g_variant_get_normal_form(variant);
|
||||
g_variant_get_data(variant);
|
||||
return 0;
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include "glib/glib.h"
|
||||
#include <stdint.h>
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
const gchar* gdata = (const gchar*)data;
|
||||
g_autoptr(GVariant) variant =
|
||||
g_variant_parse(NULL, gdata, gdata + size, NULL, NULL);
|
||||
if (!variant)
|
||||
return 0;
|
||||
g_autofree gchar* text = g_variant_print(variant, TRUE);
|
||||
return 0;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
"'"
|
||||
"("
|
||||
")"
|
||||
"<"
|
||||
">"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"*"
|
||||
"?"
|
||||
"@"
|
||||
"boolean"
|
||||
"byte"
|
||||
"double"
|
||||
"false"
|
||||
"handle"
|
||||
"int16"
|
||||
"int32"
|
||||
"int64"
|
||||
"just"
|
||||
"nothing"
|
||||
"objectpath"
|
||||
"signature"
|
||||
"string"
|
||||
"true"
|
||||
"uint16"
|
||||
"uint32"
|
||||
"uint64"
|
|
@ -8,3 +8,4 @@ sanitizers:
|
|||
- address
|
||||
- undefined
|
||||
- memory
|
||||
help_url: https://gitlab.gnome.org/GNOME/glib/tree/master/fuzzing#how-to-reproduce-oss-fuzz-bugs-locally
|
||||
|
|
Loading…
Reference in New Issue