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

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

Issue 2243763002: [libFuzzer] Ensure that sqlite3_prepare_v2_fuzzer never writes to disk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo unrelated changes. Created 4 years, 4 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 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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <array> 9 #include <array>
10 #include <string> 10 #include <string>
(...skipping 24 matching lines...) Expand all
35 35
36 // Entry point for LibFuzzer. 36 // Entry point for LibFuzzer.
37 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 37 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
38 if (size < 2) 38 if (size < 2)
39 return 0; 39 return 0;
40 40
41 if (checkForBadKeyword(data, size)) 41 if (checkForBadKeyword(data, size))
42 return 0; 42 return 0;
43 43
44 sqlite3* db; 44 sqlite3* db;
45 if (SQLITE_OK != sqlite3_open(":memory:", &db)) 45 int return_code = sqlite3_open_v2(
46 "db.db",
47 &db,
48 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);
49
50
51 if (SQLITE_OK != return_code)
46 return 0; 52 return 0;
47 53
48 // Use first byte as random selector for other parameters. 54 // Use first byte as random selector for other parameters.
49 int selector = data[0]; 55 int selector = data[0];
50 56
51 // To cover both cases when progress_handler is used and isn't used. 57 // To cover both cases when progress_handler is used and isn't used.
52 if (selector & 1) 58 if (selector & 1)
53 sqlite3_progress_handler(db, 4, &Progress, NULL); 59 sqlite3_progress_handler(db, 4, &Progress, NULL);
54 else 60 else
55 sqlite3_progress_handler(db, 0, NULL, NULL); 61 sqlite3_progress_handler(db, 0, NULL, NULL);
(...skipping 10 matching lines...) Expand all
66 if (sqlite3_step(statement) != SQLITE_ROW) 72 if (sqlite3_step(statement) != SQLITE_ROW)
67 break; 73 break;
68 } 74 }
69 75
70 sqlite3_finalize(statement); 76 sqlite3_finalize(statement);
71 } 77 }
72 78
73 sqlite3_close(db); 79 sqlite3_close(db);
74 return 0; 80 return 0;
75 } 81 }
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