Coverage Report

Created: 2026-05-14 06:54

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