2 * Unix SMB/CIFS implementation.
3 * Windows NT registry I/O library
4 * Copyright (C) Michael Hanselmann 2019
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "fuzzing/fuzzing.h"
22 #include "system/filesys.h"
23 #include "lib/util/fault.h"
24 #include "registry/reg_objects.h"
25 #include "registry/regfio.h"
28 static char filename
[128];
30 int LLVMFuzzerInitialize(int *argc
, char ***argv
)
34 (void)snprintf(filename
, sizeof(filename
), "/proc/self/fd/%d", fileno(fp
));
39 int LLVMFuzzerTestOneInput(const uint8_t *buf
, size_t len
)
42 REGF_NK_REC
*nk
, *subkey
;
45 (void)fwrite(buf
, len
, 1, fp
);
48 regfile
= regfio_open(filename
, O_RDONLY
, 0600);
53 regfile
->ignore_checksums
= true;
55 nk
= regfio_rootkey(regfile
);
58 while ((subkey
= regfio_fetch_subkey(regfile
, nk
))) {
63 if (regfile
!= NULL
) {
64 regfio_close(regfile
);