Line | Count | Source |
1 | | /* |
2 | | # Copyright 2022 Google LLC |
3 | | # |
4 | | # Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | # you may not use this file except in compliance with the License. |
6 | | # You may obtain a copy of the License at |
7 | | # |
8 | | # http://www.apache.org/licenses/LICENSE-2.0 |
9 | | # |
10 | | # Unless required by applicable law or agreed to in writing, software |
11 | | # distributed under the License is distributed on an "AS IS" BASIS, |
12 | | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | # See the License for the specific language governing permissions and |
14 | | # limitations under the License. |
15 | | # |
16 | | */ |
17 | | #include <stddef.h> |
18 | | #include <stdint.h> |
19 | | |
20 | | #include "dbus/message.h" |
21 | | |
22 | 3.25k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
23 | 3.25k | _c_cleanup_(message_unrefp) Message *message = NULL; |
24 | 3.25k | MessageHeader *header = (void *)data; |
25 | 3.25k | int r; |
26 | | |
27 | 3.25k | if (size < sizeof(MessageHeader)) |
28 | 6 | return 0; |
29 | | |
30 | 3.24k | r = message_new_incoming(&message, *header); |
31 | 3.24k | if (r != 0) |
32 | 39 | return 0; |
33 | | |
34 | 3.20k | if (message->n_data > size) |
35 | 67 | return 0; |
36 | | |
37 | 3.13k | memcpy(message->data + sizeof(*header), data + sizeof(*header), message->n_data - sizeof(*header)); |
38 | | |
39 | 3.13k | r = message_parse_metadata(message); |
40 | 3.13k | if (r) |
41 | 2.79k | return 0; |
42 | | |
43 | 348 | message_stitch_sender(message, 1); |
44 | | |
45 | 348 | return 0; |
46 | 3.13k | } |