pidgin/pidgin

Add fuzzing support for some libpurple features
release-2.x.y
2021-06-24, Jordy Zomer <>
97c51d97d375
Add fuzzing support for some libpurple features

Testing Done:
Hi!

I built and tested all of these fuzzers for libpurple.

You can build them by first building pidgin/libpurple with `--enable-fuzzing` then going into `libpurple/tests` and run `make check`. After that you can run these fuzzers. With a dictionary if you want :)

for example:
```bash
$ ./fuzz_markup_strip_html -dict=dictionaries/html.dict
Dictionary: 465 entries
INFO: Seed: 2274862685
INFO: Loaded 1 modules (3 inline 8-bit counters): 3 [0x5a4ec0, 0x5a4ec3),
INFO: Loaded 1 PC tables (3 PCs): 3 [0x568ee8,0x568f18),
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2 INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 30Mb
#1048576 pulse cov: 2 ft: 2 corp: 1/1b lim: 4096 exec/s: 524288 rss: 789Mb
#2097152 pulse cov: 2 ft: 2 corp: 1/1b lim: 4096 exec/s: 524288 rss: 792Mb
```

Best Regards,

Jordy Zomer

Reviewed at https://reviews.imfreedom.org/r/760/
if HAVE_CHECK
TESTS=check_libpurple
clean-local:
-rm -rf libpurple..
check_PROGRAMS=check_libpurple
if FUZZ
fuzz_programs=\
fuzz_html_to_xhtml \
fuzz_jabber_caps \
fuzz_jabber_id_new \
fuzz_markup_strip_html \
fuzz_mime \
fuzz_xmlnode
check_PROGRAMS+=$(fuzz_programs)
endif
check_libpurple_SOURCES=\
check_libpurple.c \
tests.h \
test_cipher.c \
test_jabber_caps.c \
test_jabber_digest_md5.c \
test_jabber_jutil.c \
test_jabber_scram.c \
test_util.c \
test_xmlnode.c \
$(top_builddir)/libpurple/util.h
check_libpurple_CFLAGS=\
@CHECK_CFLAGS@ \
$(GLIB_CFLAGS) \
$(DEBUG_CFLAGS) \
$(LIBXML_CFLAGS) \
-I.. \
-I$(top_srcdir)/libpurple \
-DBUILDDIR=\"$(top_builddir)\"
check_libpurple_LDADD=\
$(top_builddir)/libpurple/protocols/jabber/libjabber.la \
$(top_builddir)/libpurple/libpurple.la \
@CHECK_LIBS@ \
$(GLIB_LIBS)
if FUZZ
fuzz_xmlnode_SOURCES=fuzz_xmlnode.c
fuzz_xmlnode_LDADD=$(check_libpurple_LDADD)
fuzz_xmlnode_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
fuzz_jabber_id_new_SOURCES=fuzz_jabber_id_new.c
fuzz_jabber_id_new_LDADD=$(check_libpurple_LDADD)
fuzz_jabber_id_new_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
fuzz_jabber_caps_SOURCES=fuzz_jabber_caps.c
fuzz_jabber_caps_LDADD=$(check_libpurple_LDADD)
fuzz_jabber_caps_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
fuzz_mime_SOURCES=fuzz_mime.c
fuzz_mime_LDADD=$(check_libpurple_LDADD)
fuzz_mime_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
fuzz_html_to_xhtml_SOURCES=fuzz_html_to_xhtml.c
fuzz_html_to_xhtml_LDADD=$(check_libpurple_LDADD)
fuzz_html_to_xhtml_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
fuzz_markup_strip_html_SOURCES=fuzz_markup_strip_html.c
fuzz_markup_strip_html_LDADD=$(check_libpurple_LDADD)
fuzz_markup_strip_html_CFLAGS=-fsanitize=fuzzer,address $(check_libpurple_CFLAGS)
endif
endif