OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This fuzzer is simplified & cleaned up pdfium/samples/pdfium_test.cc | 5 // This fuzzer is simplified & cleaned up pdfium/samples/pdfium_test.cc |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 static void RenderPdf(const char* pBuf, size_t len) { | 85 static void RenderPdf(const char* pBuf, size_t len) { |
86 IPDF_JSPLATFORM platform_callbacks; | 86 IPDF_JSPLATFORM platform_callbacks; |
87 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); | 87 memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); |
88 platform_callbacks.version = 3; | 88 platform_callbacks.version = 3; |
89 platform_callbacks.app_alert = ExampleAppAlert; | 89 platform_callbacks.app_alert = ExampleAppAlert; |
90 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; | 90 platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; |
91 | 91 |
92 FPDF_FORMFILLINFO form_callbacks; | 92 FPDF_FORMFILLINFO form_callbacks; |
93 memset(&form_callbacks, '\0', sizeof(form_callbacks)); | 93 memset(&form_callbacks, '\0', sizeof(form_callbacks)); |
| 94 #ifdef PDF_ENABLE_XFA |
| 95 form_callbacks.version = 2; |
| 96 #else // PDF_ENABLE_XFA |
94 form_callbacks.version = 1; | 97 form_callbacks.version = 1; |
| 98 #endif // PDF_ENABLE_XFA |
95 form_callbacks.m_pJsPlatform = &platform_callbacks; | 99 form_callbacks.m_pJsPlatform = &platform_callbacks; |
96 | 100 |
97 TestLoader loader(pBuf, len); | 101 TestLoader loader(pBuf, len); |
98 FPDF_FILEACCESS file_access; | 102 FPDF_FILEACCESS file_access; |
99 memset(&file_access, '\0', sizeof(file_access)); | 103 memset(&file_access, '\0', sizeof(file_access)); |
100 file_access.m_FileLen = static_cast<unsigned long>(len); | 104 file_access.m_FileLen = static_cast<unsigned long>(len); |
101 file_access.m_GetBlock = TestLoader::GetBlock; | 105 file_access.m_GetBlock = TestLoader::GetBlock; |
102 file_access.m_Param = &loader; | 106 file_access.m_Param = &loader; |
103 | 107 |
104 FX_FILEAVAIL file_avail; | 108 FX_FILEAVAIL file_avail; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 140 } |
137 | 141 |
138 if (!doc) { | 142 if (!doc) { |
139 FPDFAvail_Destroy(pdf_avail); | 143 FPDFAvail_Destroy(pdf_avail); |
140 return; | 144 return; |
141 } | 145 } |
142 | 146 |
143 (void)FPDF_GetDocPermissions(doc); | 147 (void)FPDF_GetDocPermissions(doc); |
144 | 148 |
145 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); | 149 FPDF_FORMHANDLE form = FPDFDOC_InitFormFillEnvironment(doc, &form_callbacks); |
| 150 |
| 151 #ifdef PDF_ENABLE_XFA |
| 152 int doc_type = DOCTYPE_PDF; |
| 153 if (FPDF_HasXFAField(doc, &doc_type) && doc_type != DOCTYPE_PDF) |
| 154 FPDF_LoadXFA(doc); |
| 155 #endif // PDF_ENABLE_XFA |
| 156 |
146 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); | 157 FPDF_SetFormFieldHighlightColor(form, 0, 0xFFE4DD); |
147 FPDF_SetFormFieldHighlightAlpha(form, 100); | 158 FPDF_SetFormFieldHighlightAlpha(form, 100); |
148 | 159 |
149 FORM_DoDocumentJSAction(form); | 160 FORM_DoDocumentJSAction(form); |
150 FORM_DoDocumentOpenAction(form); | 161 FORM_DoDocumentOpenAction(form); |
151 | 162 |
152 int page_count = FPDF_GetPageCount(doc); | 163 int page_count = FPDF_GetPageCount(doc); |
153 | 164 |
154 for (int i = 0; i < page_count; ++i) { | 165 for (int i = 0; i < page_count; ++i) { |
155 if (bIsLinearized) { | 166 if (bIsLinearized) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 FPDF_LIBRARY_CONFIG config; | 224 FPDF_LIBRARY_CONFIG config; |
214 UNSUPPORT_INFO unsupport_info; | 225 UNSUPPORT_INFO unsupport_info; |
215 }; | 226 }; |
216 | 227 |
217 static TestCase* testCase = new TestCase(); | 228 static TestCase* testCase = new TestCase(); |
218 | 229 |
219 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 230 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
220 RenderPdf(reinterpret_cast<const char*>(data), size); | 231 RenderPdf(reinterpret_cast<const char*>(data), size); |
221 return 0; | 232 return 0; |
222 } | 233 } |
OLD | NEW |