Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/pdf/pdf_int.h
Line
Count
Source
1
/* Copyright (C) 2018-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
#ifndef PDF_INTERPRETER
17
#define PDF_INTERPRETER
18
19
#include "ghostpdf.h"
20
#include "pdf_types.h"
21
22
23
static inline bool ishex(char c)
24
550M
{
25
550M
    if (c < 0x30)
26
554k
        return false;
27
28
549M
    if (c > 0x39) {
29
98.6M
        if (c > 'F') {
30
94.5M
            if (c < 'a')
31
99.2k
                return false;
32
94.4M
            if (c > 'f')
33
379k
                return false;
34
94.1M
            return true;
35
94.4M
        } else {
36
4.04M
            if (c < 'A')
37
63.9k
                return false;
38
3.97M
            return true;
39
4.04M
        }
40
98.6M
    } else
41
451M
        return true;
42
549M
}
Unexecuted instantiation: zpdfops.c:ishex
Unexecuted instantiation: pdf_loop_detect.c:ishex
Unexecuted instantiation: ghostpdf.c:ishex
Unexecuted instantiation: pdf_dict.c:ishex
Unexecuted instantiation: pdf_array.c:ishex
Unexecuted instantiation: pdf_xref.c:ishex
pdf_int.c:ishex
Line
Count
Source
24
550M
{
25
550M
    if (c < 0x30)
26
554k
        return false;
27
28
549M
    if (c > 0x39) {
29
98.6M
        if (c > 'F') {
30
94.5M
            if (c < 'a')
31
99.2k
                return false;
32
94.4M
            if (c > 'f')
33
379k
                return false;
34
94.1M
            return true;
35
94.4M
        } else {
36
4.04M
            if (c < 'A')
37
63.9k
                return false;
38
3.97M
            return true;
39
4.04M
        }
40
98.6M
    } else
41
451M
        return true;
42
549M
}
Unexecuted instantiation: pdf_file.c:ishex
Unexecuted instantiation: pdf_path.c:ishex
Unexecuted instantiation: pdf_colour.c:ishex
Unexecuted instantiation: pdf_pattern.c:ishex
Unexecuted instantiation: pdf_gstate.c:ishex
Unexecuted instantiation: pdf_stack.c:ishex
Unexecuted instantiation: pdf_image.c:ishex
Unexecuted instantiation: pdf_page.c:ishex
Unexecuted instantiation: pdf_annot.c:ishex
Unexecuted instantiation: pdf_mark.c:ishex
Unexecuted instantiation: pdf_font.c:ishex
Unexecuted instantiation: pdf_font0.c:ishex
Unexecuted instantiation: pdf_font1.c:ishex
Unexecuted instantiation: pdf_font1C.c:ishex
Unexecuted instantiation: pdf_fontps.c:ishex
Unexecuted instantiation: pdf_font3.c:ishex
Unexecuted instantiation: pdf_fontTT.c:ishex
Unexecuted instantiation: pdf_font11.c:ishex
Unexecuted instantiation: pdf_cmap.c:ishex
Unexecuted instantiation: pdf_fmap.c:ishex
Unexecuted instantiation: pdf_text.c:ishex
Unexecuted instantiation: pdf_shading.c:ishex
Unexecuted instantiation: pdf_func.c:ishex
Unexecuted instantiation: pdf_trans.c:ishex
Unexecuted instantiation: pdf_device.c:ishex
Unexecuted instantiation: pdf_misc.c:ishex
Unexecuted instantiation: pdf_optcontent.c:ishex
Unexecuted instantiation: pdf_check.c:ishex
Unexecuted instantiation: pdf_sec.c:ishex
Unexecuted instantiation: pdf_utf8.c:ishex
Unexecuted instantiation: pdf_deref.c:ishex
Unexecuted instantiation: pdf_repair.c:ishex
Unexecuted instantiation: pdf_obj.c:ishex
Unexecuted instantiation: pdf_doc.c:ishex
Unexecuted instantiation: pdf_fapi.c:ishex
43
44
/* You must ensure the character is a hex character before calling this, no error trapping here */
45
static inline int fromhex(char c)
46
545M
{
47
545M
    if (c > 0x39) {
48
97.7M
        if (c > 'F') {
49
93.9M
            return c - 0x57;
50
93.9M
        } else {
51
3.77M
            return c - 0x37;
52
3.77M
        }
53
97.7M
    } else
54
448M
        return c - 0x30;
55
545M
}
Unexecuted instantiation: zpdfops.c:fromhex
Unexecuted instantiation: pdf_loop_detect.c:fromhex
Unexecuted instantiation: ghostpdf.c:fromhex
Unexecuted instantiation: pdf_dict.c:fromhex
Unexecuted instantiation: pdf_array.c:fromhex
Unexecuted instantiation: pdf_xref.c:fromhex
pdf_int.c:fromhex
Line
Count
Source
46
545M
{
47
545M
    if (c > 0x39) {
48
97.7M
        if (c > 'F') {
49
93.9M
            return c - 0x57;
50
93.9M
        } else {
51
3.77M
            return c - 0x37;
52
3.77M
        }
53
97.7M
    } else
54
448M
        return c - 0x30;
55
545M
}
Unexecuted instantiation: pdf_file.c:fromhex
Unexecuted instantiation: pdf_path.c:fromhex
Unexecuted instantiation: pdf_colour.c:fromhex
Unexecuted instantiation: pdf_pattern.c:fromhex
Unexecuted instantiation: pdf_gstate.c:fromhex
Unexecuted instantiation: pdf_stack.c:fromhex
Unexecuted instantiation: pdf_image.c:fromhex
Unexecuted instantiation: pdf_page.c:fromhex
Unexecuted instantiation: pdf_annot.c:fromhex
Unexecuted instantiation: pdf_mark.c:fromhex
Unexecuted instantiation: pdf_font.c:fromhex
Unexecuted instantiation: pdf_font0.c:fromhex
Unexecuted instantiation: pdf_font1.c:fromhex
Unexecuted instantiation: pdf_font1C.c:fromhex
Unexecuted instantiation: pdf_fontps.c:fromhex
Unexecuted instantiation: pdf_font3.c:fromhex
Unexecuted instantiation: pdf_fontTT.c:fromhex
Unexecuted instantiation: pdf_font11.c:fromhex
Unexecuted instantiation: pdf_cmap.c:fromhex
Unexecuted instantiation: pdf_fmap.c:fromhex
Unexecuted instantiation: pdf_text.c:fromhex
Unexecuted instantiation: pdf_shading.c:fromhex
Unexecuted instantiation: pdf_func.c:fromhex
Unexecuted instantiation: pdf_trans.c:fromhex
Unexecuted instantiation: pdf_device.c:fromhex
Unexecuted instantiation: pdf_misc.c:fromhex
Unexecuted instantiation: pdf_optcontent.c:fromhex
Unexecuted instantiation: pdf_check.c:fromhex
Unexecuted instantiation: pdf_sec.c:fromhex
Unexecuted instantiation: pdf_utf8.c:fromhex
Unexecuted instantiation: pdf_deref.c:fromhex
Unexecuted instantiation: pdf_repair.c:fromhex
Unexecuted instantiation: pdf_obj.c:fromhex
Unexecuted instantiation: pdf_doc.c:fromhex
Unexecuted instantiation: pdf_fapi.c:fromhex
56
57
int pdfi_skip_white(pdf_context *ctx, pdf_c_stream *s);
58
int pdfi_skip_eol(pdf_context *ctx, pdf_c_stream *s);
59
int pdfi_skip_comment(pdf_context *ctx, pdf_c_stream *s);
60
int pdfi_read_token(pdf_context *ctx, pdf_c_stream *s, uint32_t indirect_num, uint32_t indirect_gen);
61
62
int pdfi_name_alloc(pdf_context *ctx, byte *key, uint32_t size, pdf_obj **o);
63
64
int pdfi_read_dict(pdf_context *ctx, pdf_c_stream *s, uint32_t indirect_num, uint32_t indirect_gen);
65
66
int pdfi_read_bare_int(pdf_context *ctx, pdf_c_stream *s, int *parsed_int);
67
int pdfi_read_bare_keyword(pdf_context *ctx, pdf_c_stream *s);
68
69
void local_save_stream_state(pdf_context *ctx, stream_save *local_save);
70
void local_restore_stream_state(pdf_context *ctx, stream_save *local_save);
71
void cleanup_context_interpretation(pdf_context *ctx, stream_save *local_save);
72
void initialise_stream_save(pdf_context *ctx);
73
int pdfi_run_context(pdf_context *ctx, pdf_stream *stream_obj, pdf_dict *page_dict, bool stoponerror, const char *desc);
74
int pdfi_interpret_inner_content_buffer(pdf_context *ctx, byte *content_data, uint32_t content_length,
75
                                        pdf_dict *stream_dict, pdf_dict *page_dict,
76
                                        bool stoponerror, const char *desc);
77
int pdfi_interpret_inner_content_c_string(pdf_context *ctx, char *content_string,
78
                                          pdf_dict *stream_dict, pdf_dict *page_dict,
79
                                          bool stoponerror, const char *desc);
80
int pdfi_interpret_inner_content_string(pdf_context *ctx, pdf_string *content_string,
81
                                        pdf_dict *stream_dict, pdf_dict *page_dict,
82
                                        bool stoponerror, const char *desc);
83
int pdfi_interpret_inner_content_stream(pdf_context *ctx, pdf_stream *stream_obj, pdf_dict *page_dict, bool stoponerror, const char *desc);
84
int pdfi_interpret_content_stream(pdf_context *ctx, pdf_c_stream *content_stream, pdf_stream *stream_obj, pdf_dict *page_dict);
85
86
#endif