2 Fuzzing ldb_comparison_fold()
3 Copyright (C) Catalyst IT 2020
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "fuzzing/fuzzing.h"
20 #include "lib/ldb/include/ldb.h"
21 #include "lib/ldb/include/ldb_handlers.h"
23 int LLVMFuzzerInitialize(int *argc
, char ***argv
)
29 int LLVMFuzzerTestOneInput(const uint8_t *input
, size_t len
)
31 struct ldb_val v1
, v2
;
32 struct ldb_context
*ldb
= NULL
;
38 v1
.length
= PULL_LE_U16(input
, 0);
39 if (v1
.length
> len
- 2) {
40 /* the exact case of v2.length == 0 is still available */
46 ldb
= ldb_init(NULL
, NULL
);
51 v1
.data
= talloc_memdup(ldb
, input
, v1
.length
);
52 v2
.length
= len
- v1
.length
;
53 v2
.data
= talloc_memdup(ldb
, input
+ v1
.length
, v2
.length
);
55 ldb_comparison_fold(ldb
, ldb
, &v1
, &v2
);