/src/krb5/fuzzing/Fuzz_chpw.c
Line | Count | Source |
1 | | /* Copyright 2022 Google LLC |
2 | | Licensed under the Apache License, Version 2.0 (the "License"); |
3 | | you may not use this file except in compliance with the License. |
4 | | You may obtain a copy of the License at |
5 | | http://www.apache.org/licenses/LICENSE-2.0 |
6 | | Unless required by applicable law or agreed to in writing, software |
7 | | distributed under the License is distributed on an "AS IS" BASIS, |
8 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
9 | | See the License for the specific language governing permissions and |
10 | | limitations under the License. |
11 | | */ |
12 | | #include <stdio.h> |
13 | | #include <stdlib.h> |
14 | | #include <stdint.h> |
15 | | #include <string.h> |
16 | | |
17 | | #include "k5-int.h" |
18 | | #include "krb5.h" |
19 | | |
20 | 600 | #define kMinInputLength 20 |
21 | 290 | #define kMaxInputLength 100 |
22 | | |
23 | | extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) |
24 | 300 | {//src/tests/misc/test_chpw_message.c |
25 | | |
26 | 300 | if (Size < kMinInputLength || Size > kMaxInputLength){ |
27 | 41 | return 0; |
28 | 41 | } |
29 | | |
30 | 259 | char *msg; |
31 | 259 | krb5_data DataInput; |
32 | 259 | krb5_context context; |
33 | | |
34 | 259 | krb5_init_context(&context); |
35 | | |
36 | 259 | DataInput = make_data((void *)Data, Size); |
37 | | |
38 | 259 | krb5_chpw_message(context, &DataInput, &msg); |
39 | | |
40 | 259 | free(msg); |
41 | 259 | krb5_free_context(context); |
42 | 259 | return 0; |
43 | 300 | } |