/src/h5_extended_fuzzer.c
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 | 2.01k | { |
19 | 2.01k | char filename[256]; |
20 | 2.01k | sprintf(filename, "/tmp/libfuzzer.%d", getpid()); |
21 | | |
22 | 2.01k | FILE *fp = fopen(filename, "wb"); |
23 | 2.01k | if (!fp) { |
24 | 0 | return 0; |
25 | 0 | } |
26 | 2.01k | fwrite(data, size, 1, fp); |
27 | 2.01k | fclose(fp); |
28 | | |
29 | 2.01k | hid_t fuzz_h5_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); |
30 | 2.01k | if (fuzz_h5_id != H5I_INVALID_HID) { |
31 | 1.71k | hid_t dataset_id = H5Dopen2(fuzz_h5_id, "dsetname", H5P_DEFAULT); |
32 | 1.71k | if (dataset_id != H5I_INVALID_HID) { |
33 | 57 | hid_t attribute_id = H5Aopen_name(dataset_id, "theattr"); |
34 | 57 | if (attribute_id != H5I_INVALID_HID) { |
35 | 0 | H5Aclose(attribute_id); |
36 | 0 | } |
37 | 57 | H5Dclose(dataset_id); |
38 | 57 | } |
39 | 1.71k | H5Fclose(fuzz_h5_id); |
40 | 1.71k | } |
41 | 2.01k | return 0; |
42 | 2.01k | } |