Coverage Report

Created: 2026-01-09 06:03

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