• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

saitoha / libsixel / 24330237812

13 Apr 2026 07:00AM UTC coverage: 85.604% (-0.002%) from 85.606%
24330237812

push

github

saitoha
loader/coregraphics: reject oversized indexed provider copy

Prevent indexed decode from requesting oversized provider copies and add a minimized regression payload test.

102401 of 214234 branches covered (47.8%)

52 of 61 new or added lines in 2 files covered. (85.25%)

3019 existing lines in 8 files now uncovered.

124714 of 145687 relevant lines covered (85.6%)

17552177.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.01
/tests/cli/0031_cli_guard_missing_argument.c
1
/*
2
 * Test harness for cli_guard_missing_argument handling.
3
 */
4

5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <string.h>
8

9
#include "config.h"
10
#include "converters/cli.h"
11

12
typedef struct guard_result {
13
    int code;
14
    int missing_calls;
15
    int rewound_optind;
16
} guard_result_t;
17

18
static int g_missing_calls;
19
static int g_rewound;
20

21
static int
22
allows_leading_dash(int short_opt, void *user_data)
26✔
23
{
24
    (void)user_data;
18✔
25
    return short_opt == 'i';
26✔
26
}
27

28
static void
29
report_missing(int short_opt, void *user_data)
78✔
30
{
31
    int *last_short;
39✔
32

33
    last_short = (int *)user_data;
78✔
34
    g_missing_calls += 1;
78✔
35
    *last_short = short_opt;
78✔
36
}
78✔
37

38
static guard_result_t
39
run_guard_case(char *const *argv,
104✔
40
               char *argument,
41
               int *optind_ptr,
42
               char const *optstring,
43
               cli_option_help_t const *table,
44
               size_t table_count,
45
               int allow_dash)
46
{
47
    int report_short;
52✔
48
    int result;
52✔
49
    int starting_optind;
52✔
50

51
    report_short = 0;
104✔
52
    g_missing_calls = 0;
104✔
53
    g_rewound = 0;
104✔
54

55
    starting_optind = 0;
104✔
56
    if (optind_ptr != NULL) {
104!
57
        starting_optind = *optind_ptr;
104✔
58
    }
44✔
59

60
    result = cli_guard_missing_argument(
125✔
61
        'i',
62
        argv,
44✔
63
        argument,
44✔
64
        optind_ptr,
44✔
65
        optstring,
44✔
66
        table,
44✔
67
        table_count,
44✔
68
        allow_dash ? allows_leading_dash : NULL,
44✔
69
        NULL,
70
        report_missing,
71
        &report_short);
72

73
    if (optind_ptr != NULL
124!
74
            && *optind_ptr == starting_optind - 1
104!
75
            && allow_dash == 0) {
74!
76
        g_rewound = 1;
52✔
77
    }
22✔
78

79
    return (guard_result_t){ result, g_missing_calls, g_rewound };
104✔
80
}
24✔
81

82
int
83
test_cli_0031_cli_guard_missing_argument(int argc, char **argv)
26✔
84
{
85
    cli_option_help_t const table[] = {
26✔
86
        { 'i', "input", "--input help\n" },
87
        { 'x', "extract", "--extract help\n" },
88
    };
89
    char argv0[] = "tool";
26✔
90
    char argv1[] = "-x";
26✔
91
    char dash_value[] = "-file.six";
26✔
92
    char copied_option[] = "-x";
26✔
93
    char *args[] = { argv0, argv1, NULL };
26✔
94
    size_t table_count;
13✔
95
    int optind_value;
13✔
96
    guard_result_t result;
13✔
97
    int status;
13✔
98

99
    (void) argc;
18✔
100
    (void) argv;
18✔
101

102
    table_count = sizeof(table) / sizeof(table[0]);
26✔
103

104
    optind_value = 1;
26✔
105
    result = run_guard_case(args,
37✔
106
                             NULL,
107
                             &optind_value,
108
                             "i:",
109
                             table,
11✔
110
                             table_count,
11✔
111
                             0);
112
    status = 0;
26✔
113
    if (result.code == -1 && result.missing_calls == 1) {
26!
114
    } else {
11✔
115
        fprintf(stderr, "case 1: missing argument not reported\n");
×
UNCOV
116
        status = 1;
×
117
    }
118

119
    optind_value = 0;
26✔
120
    result = run_guard_case(args,
37✔
121
                             dash_value,
11✔
122
                             &optind_value,
123
                             "i:",
124
                             table,
11✔
125
                             table_count,
11✔
126
                             1);
127
    if (result.code == 0 && result.missing_calls == 0) {
26!
128
    } else {
11✔
129
        fprintf(stderr, "case 2: leading dash rejected\n");
×
UNCOV
130
        status = 1;
×
131
    }
132

133
    optind_value = 2;
26✔
134
    result = run_guard_case(args,
37✔
135
                             args[1],
11✔
136
                             &optind_value,
137
                             "i:",
138
                             table,
11✔
139
                             table_count,
11✔
140
                             0);
141
    if (result.code == -1 && result.missing_calls == 1 &&
34!
142
            result.rewound_optind != 0) {
19!
143
    } else {
11✔
144
        fprintf(stderr, "case 3: did not rewind recognised option\n");
×
UNCOV
145
        status = 1;
×
146
    }
147

148
    optind_value = 2;
26✔
149
    result = run_guard_case(args,
37✔
150
                             copied_option,
11✔
151
                             &optind_value,
152
                             "i:",
153
                             table,
11✔
154
                             table_count,
11✔
155
                             0);
156
    if (result.code == -1 && result.missing_calls == 1 &&
34!
157
            result.rewound_optind != 0) {
19!
158
    } else {
11✔
UNCOV
159
        fprintf(stderr, "case 4: copied argument did not rewind\n");
×
UNCOV
160
        status = 1;
×
161
    }
162

163
    return status == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
32✔
164
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc