/src/poppler/glib/tests/fuzzing/doc_attr_fuzzer.cc
Line | Count | Source |
1 | | #include <stdlib.h> |
2 | | #include <stdint.h> |
3 | | #include <string.h> |
4 | | #include <poppler.h> |
5 | | |
6 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
7 | 7.41k | { |
8 | 7.41k | GError *err = NULL; |
9 | 7.41k | PopplerDocument *doc; |
10 | 7.41k | PopplerPage *page; |
11 | 7.41k | char *buf; |
12 | 7.41k | int npages, n; |
13 | | |
14 | 7.41k | doc = poppler_document_new_from_data((char *)data, size, NULL, &err); |
15 | 7.41k | if (doc == NULL) { |
16 | 4.03k | g_error_free(err); |
17 | 4.03k | return 0; |
18 | 4.03k | } |
19 | | |
20 | 3.37k | buf = (char *)calloc(size + 1, sizeof(char)); |
21 | 3.37k | memcpy(buf, data, size); |
22 | 3.37k | buf[size] = '\0'; |
23 | | |
24 | 3.37k | poppler_document_set_author(doc, buf); |
25 | 3.37k | poppler_document_set_creator(doc, buf); |
26 | 3.37k | poppler_document_set_keywords(doc, buf); |
27 | 3.37k | poppler_document_set_producer(doc, buf); |
28 | 3.37k | poppler_document_set_subject(doc, buf); |
29 | 3.37k | poppler_document_set_title(doc, buf); |
30 | | |
31 | 3.37k | free(buf); |
32 | | |
33 | 3.37k | poppler_document_has_javascript(doc); |
34 | | |
35 | 3.37k | g_object_unref(doc); |
36 | 3.37k | return 0; |
37 | 7.41k | } |