OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <stddef.h> | |
6 | |
7 #include "third_party/sqlite/sqlite3.h" | |
8 | |
9 static int Progress(void *not_used_ptr) { | |
10 return 1; | |
11 } | |
12 | |
13 // Entry point for LibFuzzer. | |
14 extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) { | |
15 if (size < 2) | |
16 return 0; | |
17 | |
18 sqlite3* db; | |
19 if (SQLITE_OK != sqlite3_open(":memory:", &db)) | |
20 return 0; | |
21 | |
22 if (data[0] & 1) | |
aizatsky
2015/12/23 21:04:33
I suggest you add a comment at the top about how y
inferno
2015/12/26 22:33:06
nit: +1 to Mike's comment. I also suggest putting
mmoroz
2016/01/15 19:08:16
Done.
| |
23 sqlite3_progress_handler(db, 10000, &Progress, NULL); | |
24 else | |
25 sqlite3_progress_handler(db, 0, NULL, NULL); | |
26 | |
27 sqlite3_stmt* statement = NULL; | |
28 int r = sqlite3_prepare_v2(db, (const char*)(data + 1), size - 1, | |
inferno
2015/12/26 22:33:07
s/r/result
mmoroz
2016/01/15 19:08:16
Done.
| |
29 &statement, NULL); | |
30 if (r == SQLITE_OK) { | |
31 for (int i = 0; i < (data[0] >> 1); i++) { | |
inferno
2015/12/26 22:33:07
What is reason for >> 1, also use the local define
mmoroz
2016/01/15 19:08:16
We used least significant bit above for sqlite3_pr
| |
32 if (sqlite3_step(statement) != SQLITE_ROW) | |
33 break; | |
34 } | |
35 | |
36 sqlite3_finalize(statement); | |
37 } | |
38 | |
39 sqlite3_close(db); | |
40 return 0; | |
41 } | |
OLD | NEW |