Coverage Report

Created: 2025-03-06 07:58

/src/gnutls/lib/minitasn1/parser_aux.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2000-2025 Free Software Foundation, Inc.
3
 *
4
 * This file is part of LIBTASN1.
5
 *
6
 * The LIBTASN1 library is free software; you can redistribute it
7
 * and/or modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful, but
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see
18
 * <https://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef _PARSER_AUX_H
22
# define _PARSER_AUX_H
23
24
/***********************************************/
25
/* Type: list_type                             */
26
/* Description: type used in the list during   */
27
/* the structure creation.                     */
28
/***********************************************/
29
typedef struct list_struct
30
{
31
  asn1_node node;
32
  struct list_struct *next;
33
} list_type;
34
35
/***************************************/
36
/*  Functions used by ASN.1 parser     */
37
/***************************************/
38
asn1_node _asn1_add_static_node (list_type ** e_list, unsigned int type);
39
40
void _asn1_delete_list (list_type * e_list);
41
42
void _asn1_delete_list_and_nodes (list_type * e_list);
43
44
void _asn1_delete_node_from_list (list_type * list, asn1_node node);
45
46
asn1_node
47
_asn1_set_value (asn1_node node, const void *value, unsigned int len);
48
49
asn1_node _asn1_set_value_m (asn1_node node, void *value, unsigned int len);
50
51
asn1_node
52
_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len);
53
54
asn1_node
55
_asn1_append_value (asn1_node node, const void *value, unsigned int len);
56
57
asn1_node _asn1_set_name (asn1_node node, const char *name);
58
59
asn1_node _asn1_cpy_name (asn1_node dst, asn1_node_const src);
60
61
asn1_node _asn1_set_right (asn1_node node, asn1_node right);
62
63
asn1_node _asn1_get_last_right (asn1_node_const node);
64
65
void _asn1_remove_node (asn1_node node, unsigned int flags);
66
67
/* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */
68
0
# define LTOSTR_MAX_SIZE 22
69
char *_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]);
70
71
asn1_node _asn1_find_up (asn1_node_const node);
72
73
int _asn1_change_integer_value (asn1_node node);
74
75
0
# define EXPAND_OBJECT_ID_MAX_RECURSION 16
76
int _asn1_expand_object_id (list_type ** list, asn1_node node);
77
78
int _asn1_type_set_config (asn1_node node);
79
80
int _asn1_check_identifier (asn1_node_const node);
81
82
int _asn1_set_default_tag (asn1_node node);
83
84
/******************************************************************/
85
/* Function : _asn1_get_right                                     */
86
/* Description: returns the element pointed by the RIGHT field of */
87
/*              a NODE_ASN element.                               */
88
/* Parameters:                                                    */
89
/*   node: NODE_ASN element pointer.                              */
90
/* Return: field RIGHT of NODE.                                   */
91
/******************************************************************/
92
inline static asn1_node
93
_asn1_get_right (asn1_node_const node)
94
0
{
95
0
  if (node == NULL)
96
0
    return NULL;
97
0
  return node->right;
98
0
}
Unexecuted instantiation: coding.c:_asn1_get_right
Unexecuted instantiation: decoding.c:_asn1_get_right
Unexecuted instantiation: element.c:_asn1_get_right
Unexecuted instantiation: parser_aux.c:_asn1_get_right
Unexecuted instantiation: structure.c:_asn1_get_right
99
100
/******************************************************************/
101
/* Function : _asn1_set_down                                      */
102
/* Description: sets the field DOWN in a NODE_ASN element.        */
103
/* Parameters:                                                    */
104
/*   node: element pointer.                                       */
105
/*   down: pointer to a NODE_ASN element that you want be pointed */
106
/*          by NODE.                                              */
107
/* Return: pointer to *NODE.                                      */
108
/******************************************************************/
109
inline static asn1_node
110
_asn1_set_down (asn1_node node, asn1_node down)
111
4.38k
{
112
4.38k
  if (node == NULL)
113
0
    return node;
114
4.38k
  node->down = down;
115
4.38k
  if (down)
116
4.38k
    down->left = node;
117
4.38k
  return node;
118
4.38k
}
Unexecuted instantiation: coding.c:_asn1_set_down
Unexecuted instantiation: decoding.c:_asn1_set_down
Unexecuted instantiation: element.c:_asn1_set_down
Unexecuted instantiation: parser_aux.c:_asn1_set_down
structure.c:_asn1_set_down
Line
Count
Source
111
4.38k
{
112
4.38k
  if (node == NULL)
113
0
    return node;
114
4.38k
  node->down = down;
115
4.38k
  if (down)
116
4.38k
    down->left = node;
117
4.38k
  return node;
118
4.38k
}
119
120
/******************************************************************/
121
/* Function : _asn1_get_down                                      */
122
/* Description: returns the element pointed by the DOWN field of  */
123
/*              a NODE_ASN element.                               */
124
/* Parameters:                                                    */
125
/*   node: NODE_ASN element pointer.                              */
126
/* Return: field DOWN of NODE.                                    */
127
/******************************************************************/
128
inline static asn1_node
129
_asn1_get_down (asn1_node_const node)
130
0
{
131
0
  if (node == NULL)
132
0
    return NULL;
133
0
  return node->down;
134
0
}
Unexecuted instantiation: coding.c:_asn1_get_down
Unexecuted instantiation: decoding.c:_asn1_get_down
Unexecuted instantiation: element.c:_asn1_get_down
Unexecuted instantiation: parser_aux.c:_asn1_get_down
Unexecuted instantiation: structure.c:_asn1_get_down
135
136
/******************************************************************/
137
/* Function : _asn1_get_name                                      */
138
/* Description: returns the name of a NODE_ASN element.           */
139
/* Parameters:                                                    */
140
/*   node: NODE_ASN element pointer.                              */
141
/* Return: a null terminated string.                              */
142
/******************************************************************/
143
inline static char *
144
_asn1_get_name (asn1_node_const node)
145
0
{
146
0
  if (node == NULL)
147
0
    return NULL;
148
0
  return (char *) node->name;
149
0
}
Unexecuted instantiation: coding.c:_asn1_get_name
Unexecuted instantiation: decoding.c:_asn1_get_name
Unexecuted instantiation: element.c:_asn1_get_name
Unexecuted instantiation: parser_aux.c:_asn1_get_name
Unexecuted instantiation: structure.c:_asn1_get_name
150
151
/******************************************************************/
152
/* Function : _asn1_mod_type                                      */
153
/* Description: change the field TYPE of an NODE_ASN element.     */
154
/*              The new value is the old one | (bitwise or) the   */
155
/*              paramener VALUE.                                  */
156
/* Parameters:                                                    */
157
/*   node: NODE_ASN element pointer.                              */
158
/*   value: the integer value that must be or-ed with the current */
159
/*          value of field TYPE.                                  */
160
/* Return: NODE pointer.                                          */
161
/******************************************************************/
162
inline static asn1_node
163
_asn1_mod_type (asn1_node node, unsigned int value)
164
0
{
165
0
  if (node == NULL)
166
0
    return node;
167
0
  node->type |= value;
168
0
  return node;
169
0
}
Unexecuted instantiation: coding.c:_asn1_mod_type
Unexecuted instantiation: decoding.c:_asn1_mod_type
Unexecuted instantiation: element.c:_asn1_mod_type
Unexecuted instantiation: parser_aux.c:_asn1_mod_type
Unexecuted instantiation: structure.c:_asn1_mod_type
170
171
#endif