s3: smbd: rename_internals_fsp() has to reopen the parent directory of the target...
[Samba.git] / lib / fuzzing / fuzz_ldb_comparison_fold.c
blob08b2f590760cf91217364eb8912685cb58c42902
1 /*
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/>.
18 #include "includes.h"
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)
25 return 0;
29 int LLVMFuzzerTestOneInput(const uint8_t *input, size_t len)
31 struct ldb_val v1, v2;
32 struct ldb_context *ldb = NULL;
34 if (len < 2) {
35 return 0;
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 */
41 return 0;
43 len -= 2;
44 input += 2;
46 ldb = ldb_init(NULL, NULL);
47 if (ldb == NULL) {
48 return 0;
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);
56 talloc_free(ldb);
57 return 0;