Line | Count | Source |
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 <stdint.h> |
14 | | #include "lcms2.h" |
15 | | |
16 | | |
17 | 298 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
18 | | |
19 | 298 | if (size < 8){ |
20 | 4 | return 0; |
21 | 4 | } |
22 | | |
23 | 294 | uint32_t Row = *((uint32_t *)data); |
24 | 294 | uint32_t Col = *((uint32_t *)data+1); |
25 | | |
26 | | /* Write */ |
27 | 294 | cmsHANDLE it8; |
28 | 294 | cmsInt32Number i; |
29 | | |
30 | 294 | it8 = cmsIT8Alloc(0); |
31 | 294 | if (it8 == NULL) return 0; |
32 | | |
33 | 294 | cmsIT8SetSheetType(it8, "LCMS/TESTING"); |
34 | 294 | cmsIT8SetPropertyStr(it8, "ORIGINATOR", "1 2 3 4"); |
35 | 294 | cmsIT8SetPropertyUncooked(it8, "DESCRIPTOR", "1234"); |
36 | 294 | cmsIT8SetPropertyStr(it8, "MANUFACTURER", "3"); |
37 | 294 | cmsIT8SetPropertyDbl(it8, "CREATED", data[0] / 255.0); |
38 | 294 | cmsIT8SetPropertyDbl(it8, "SERIAL", data[1] / 255.0); |
39 | 294 | cmsIT8SetPropertyHex(it8, "MATERIAL", 0x123); |
40 | | |
41 | 294 | cmsIT8SetPropertyDbl(it8, "NUMBER_OF_SETS", 10); |
42 | 294 | cmsIT8SetPropertyDbl(it8, "NUMBER_OF_FIELDS", Row); |
43 | | |
44 | 294 | cmsIT8SetDataFormat(it8, 0, "SAMPLE_ID"); |
45 | 294 | cmsIT8SetDataFormat(it8, 1, "RGB_R"); |
46 | 294 | cmsIT8SetDataFormat(it8, 2, "RGB_G"); |
47 | 294 | cmsIT8SetDataFormat(it8, 3, "RGB_B"); |
48 | | |
49 | 3.23k | for (i=0; i < 10; i++) { |
50 | | |
51 | 2.94k | char Patch[20]; |
52 | | |
53 | 2.94k | sprintf(Patch, "P%d", i); |
54 | | |
55 | 2.94k | cmsIT8SetDataRowCol(it8, i, 0, Patch); |
56 | 2.94k | cmsIT8SetDataRowColDbl(it8, i, 1, i); |
57 | 2.94k | cmsIT8SetDataRowColDbl(it8, i, 2, i); |
58 | 2.94k | cmsIT8SetDataRowColDbl(it8, i, 3, i); |
59 | 2.94k | } |
60 | | |
61 | 294 | cmsIT8SaveToFile(it8, "TEST.IT8"); |
62 | 294 | cmsIT8Free(it8); |
63 | | |
64 | 294 | it8 = cmsIT8LoadFromFile(0, "TEST.IT8"); |
65 | 294 | if (it8 == NULL) return 0; |
66 | | |
67 | | /* Read */ |
68 | 96 | cmsIT8GetDataRowColDbl(it8,Row,Col); |
69 | 96 | cmsIT8GetPropertyDbl(it8, "DESCRIPTOR"); |
70 | 96 | cmsIT8GetDataDbl(it8, "P3", "RGB_G"); |
71 | | |
72 | 96 | cmsIT8Free(it8); |
73 | 96 | return 0; |
74 | 294 | } |