Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright 2023 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 | | |
13 | | #include "hdf5.h" |
14 | | |
15 | | #include <unistd.h> |
16 | | |
17 | | extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
18 | 7 | { |
19 | | // Some old logic with regards to skipping first byte. Leaving it here |
20 | | // to avoid affecting the clusterfuzz-generated corpus. |
21 | 7 | if (size == 0) { |
22 | 0 | return 0; |
23 | 0 | } |
24 | 7 | uint8_t decider = data[0]; |
25 | 7 | size -= 1; |
26 | 7 | data += 1; |
27 | | |
28 | 7 | char filename[256]; |
29 | 7 | sprintf(filename, "/tmp/libfuzzer.%d", getpid()); |
30 | | |
31 | 7 | FILE *fp = fopen(filename, "wb"); |
32 | 7 | if (!fp) { |
33 | 0 | return 0; |
34 | 0 | } |
35 | 7 | fwrite(data, size, 1, fp); |
36 | 7 | fclose(fp); |
37 | | |
38 | 7 | hid_t fuzz_h5_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); |
39 | 7 | if (fuzz_h5_id != H5I_INVALID_HID) { |
40 | 1 | H5Fclose(fuzz_h5_id); |
41 | 1 | } |
42 | | |
43 | 7 | return 0; |
44 | 7 | } |