Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: testing/libfuzzer/fuzzers/pdfium_fuzzer.cc

Issue 1635793002: Fix pdfium_fuzzer build failure on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stdio.h> 9 #include <stdio.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <string.h> 11 #include <string.h>
12
13 #ifdef _MSC_VER
14 #include <Windows.h>
15 #else
12 #include <unistd.h> 16 #include <unistd.h>
17 #endif
13 18
14 #include <list> 19 #include <list>
15 #include <sstream> 20 #include <sstream>
16 #include <string> 21 #include <string>
17 #include <utility> 22 #include <utility>
18 #include <vector> 23 #include <vector>
19 24
20 #include "third_party/pdfium/public/fpdf_dataavail.h" 25 #include "third_party/pdfium/public/fpdf_dataavail.h"
21 #include "third_party/pdfium/public/fpdf_ext.h" 26 #include "third_party/pdfium/public/fpdf_ext.h"
22 #include "third_party/pdfium/public/fpdf_formfill.h" 27 #include "third_party/pdfium/public/fpdf_formfill.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 RenderPage(doc, form, i); 162 RenderPage(doc, form, i);
158 } 163 }
159 164
160 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC); 165 FORM_DoDocumentAAction(form, FPDFDOC_AACTION_WC);
161 FPDFDOC_ExitFormFillEnvironment(form); 166 FPDFDOC_ExitFormFillEnvironment(form);
162 FPDF_CloseDocument(doc); 167 FPDF_CloseDocument(doc);
163 FPDFAvail_Destroy(pdf_avail); 168 FPDFAvail_Destroy(pdf_avail);
164 } 169 }
165 170
166 std::string ProgramPath() { 171 std::string ProgramPath() {
172 #ifdef _MSC_VER
173 wchar_t wpath[MAX_PATH];
174 char path[MAX_PATH];
175 DWORD res = GetModuleFileName(NULL, wpath, MAX_PATH);
176 assert(res != 0);
177 wcstombs(path, wpath, MAX_PATH);
178 return std::string(path, res);
179 #else
167 char *path = new char[PATH_MAX + 1]; 180 char *path = new char[PATH_MAX + 1];
168 assert(path); 181 assert(path);
169 ssize_t sz = readlink("/proc/self/exe", path, PATH_MAX); 182 ssize_t sz = readlink("/proc/self/exe", path, PATH_MAX);
170 assert(sz > 0); 183 assert(sz > 0);
171 std::string result(path, sz); 184 std::string result(path, sz);
172 delete[] path; 185 delete[] path;
173 return result; 186 return result;
187 #endif
174 } 188 }
175 189
176 struct TestCase { 190 struct TestCase {
177 TestCase() { 191 TestCase() {
178 InitializeV8ForPDFium(ProgramPath(), "", &natives_blob, &snapshot_blob, 192 InitializeV8ForPDFium(ProgramPath(), "", &natives_blob, &snapshot_blob,
179 &platform); 193 &platform);
180 194
181 memset(&config, '\0', sizeof(config)); 195 memset(&config, '\0', sizeof(config));
182 config.version = 2; 196 config.version = 2;
183 config.m_pUserFontPaths = nullptr; 197 config.m_pUserFontPaths = nullptr;
(...skipping 13 matching lines...) Expand all
197 FPDF_LIBRARY_CONFIG config; 211 FPDF_LIBRARY_CONFIG config;
198 UNSUPPORT_INFO unsupport_info; 212 UNSUPPORT_INFO unsupport_info;
199 }; 213 };
200 214
201 static TestCase* testCase = new TestCase(); 215 static TestCase* testCase = new TestCase();
202 216
203 extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) { 217 extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
204 RenderPdf(reinterpret_cast<const char*>(data), size); 218 RenderPdf(reinterpret_cast<const char*>(data), size);
205 return 0; 219 return 0;
206 } 220 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698