2 Fuzz dcerpc_parse_binding
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 "librpc/gen_ndr/ndr_epmapper.h"
20 #include "librpc/rpc/dcerpc.h"
21 #include "fuzzing/fuzzing.h"
23 #define MAX_LENGTH (1024 * 10)
24 char buf
[MAX_LENGTH
+ 1];
27 int LLVMFuzzerTestOneInput(const uint8_t *input
, size_t len
)
29 TALLOC_CTX
*mem_ctx
= NULL
;
30 struct dcerpc_binding
*binding
= NULL
;
31 struct dcerpc_binding
*dup
= NULL
;
32 struct epm_tower tower
;
36 if (len
> MAX_LENGTH
) {
40 memcpy(buf
, input
, len
);
43 mem_ctx
= talloc_new(NULL
);
44 status
= dcerpc_parse_binding(mem_ctx
, buf
, &binding
);
46 if (! NT_STATUS_IS_OK(status
)) {
51 /* If the string parses, we try manipulating it a bit */
53 dcerpc_binding_string(mem_ctx
, binding
);
54 dcerpc_binding_get_abstract_syntax(binding
);
55 dup
= dcerpc_binding_dup(mem_ctx
, binding
);
57 status
= dcerpc_binding_build_tower(mem_ctx
,
60 if (NT_STATUS_IS_OK(status
)) {
61 status
= dcerpc_binding_from_tower(mem_ctx
,
66 guid
= dcerpc_binding_get_object(binding
);
73 int LLVMFuzzerInitialize(int *argc
, char ***argv
)