[gnutls-devel] libtasn1 | Add initial fuzzing implementation (!38)

Development of GNU's TLS library gnutls-devel at lists.gnutls.org
Wed Jul 31 16:30:05 CEST 2019




Tim Rühsen commented on a discussion on fuzz/libtasn1_parser2tree_fuzzer.c: https://gitlab.com/gnutls/libtasn1/merge_requests/38#note_198319052

> +#include <config.h>
> +
> +#include <stdlib.h> // malloc, free
> +#include <string.h> // strcmp, memcpy
> +
> +#include "libtasn1.h"
> +#include "fuzzer.h"
> +
> +static const uint8_t *g_data;
> +static size_t g_size;
> +
> +//#if defined HAVE_DLFCN_H && defined HAVE_FMEMOPEN
> +#include <dlfcn.h>
> +#ifdef RTLD_NEXT /* Not defined e.g. on CygWin */
> +
> +FILE *fopen(const char *pathname, const char *mode) {

The real 'fix' would be to have a function `asn1_parser2tree_mem()` which takes a block of memory instead of a filename. Then we don't have to rely on `dlsym()` and `fmemopen()` which both are not portable. It would also simplify and speed up `_asn1_yylex()` when using no I/O in there.

If you agree, let's open another issue for that.

BTW, how to write fuzzable code (also see comments): https://twitter.com/johnregehr/status/1154888675810934784

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/libtasn1/merge_requests/38#note_198319052
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20190731/c1c6f25b/attachment.html>


More information about the Gnutls-devel mailing list