2020-11-22 20:52:30 +00:00
|
|
|
#include <cairo.h>
|
2020-10-05 08:03:04 +00:00
|
|
|
#include <cairo-pdf.h>
|
|
|
|
|
#include "fuzzer_temp_file.h"
|
|
|
|
|
|
2020-11-26 15:40:28 +00:00
|
|
|
const double width_in_inches = 3;
|
|
|
|
|
const double height_in_inches = 3;
|
|
|
|
|
const double width_in_points = width_in_inches * 72.0;
|
|
|
|
|
const double height_in_points = height_in_inches * 72.0;
|
2020-10-05 08:03:04 +00:00
|
|
|
|
|
|
|
|
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
|
|
|
cairo_t *cr;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
cairo_status_t status;
|
|
|
|
|
|
|
|
|
|
char *tmpfile = fuzzer_get_tmpfile(data, size);
|
2020-11-26 15:40:28 +00:00
|
|
|
surface = cairo_pdf_surface_create(tmpfile, width_in_points, height_in_points);
|
2020-10-05 08:03:04 +00:00
|
|
|
status = cairo_surface_status(surface);
|
|
|
|
|
if (status != CAIRO_STATUS_SUCCESS) {
|
|
|
|
|
fuzzer_release_tmpfile(tmpfile);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-26 15:09:38 +00:00
|
|
|
char *buf = (char *) calloc(size + 1, sizeof(char));
|
2020-11-16 14:17:31 +00:00
|
|
|
memcpy(buf, data, size);
|
|
|
|
|
buf[size] = '\0';
|
|
|
|
|
|
|
|
|
|
cairo_pdf_surface_set_metadata(surface, CAIRO_PDF_METADATA_TITLE, buf);
|
|
|
|
|
cr = cairo_create(surface);
|
|
|
|
|
cairo_tag_begin(cr, buf, NULL);
|
|
|
|
|
cairo_tag_end(cr, buf);
|
2020-10-05 08:03:04 +00:00
|
|
|
|
|
|
|
|
cairo_destroy(cr);
|
2020-11-16 14:17:31 +00:00
|
|
|
cairo_surface_destroy(surface);
|
2020-11-24 23:06:51 +00:00
|
|
|
free(buf);
|
2020-10-05 08:03:04 +00:00
|
|
|
fuzzer_release_tmpfile(tmpfile);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|