Debian Codegraph @

src/OVAL/oval_entity.c

raw symbols SCIP
1 /**
2 * @file oval_entity.c
3 * \brief Open Vulnerability and Assessment Language
4 *
5 * See more details at http://oval.mitre.org/
6 */
7
8 /*
9 * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina.
10 * All Rights Reserved.
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 * Authors:
27 * "David Niemoller" <[email protected]>
28 */
29
30 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
31 #include <config.h>cxx . . $ `<file>/build/config.h`/
32 #endif
33
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37
38 #include <libxml/tree.h>
39
40 #include "oval_definitions_impl.h"cxx . . $ `<file>/src/OVAL/oval_definitions_impl.h`/
41 #include "adt/oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/
42 #include "oval_agent_api_impl.h"cxx . . $ `<file>/src/OVAL/oval_agent_api_impl.h`/
43 #include "oval_parser_impl.h"cxx . . $ `<file>/src/OVAL/oval_parser_impl.h`/
44
45 #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/
46 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
47 #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/
48 #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/
49
50 /***************************************************************************/
51 /* Variable definitions
52 * */
53
54 struct oval_entitycxx . . $ oval_entity# {
55 struct oval_definition_modelcxx . . $ oval_definition_model# *modelcxx . . $ oval_entity#model.;
56 oval_entity_type_tcxx . . $ oval_entity_type_t# typecxx . . $ oval_entity#type.;
57 oval_datatype_tcxx . . $ oval_datatype_t# datatypecxx . . $ oval_entity#datatype.;
58 oval_operation_tcxx . . $ oval_operation_t# operationcxx . . $ oval_entity#operation.;
59 int maskcxx . . $ oval_entity#mask.;
60 oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# varref_typecxx . . $ oval_entity#varref_type.;
61 char *namecxx . . $ oval_entity#name.;
62 struct oval_variablecxx . . $ oval_variable# *variablecxx . . $ oval_entity#variable.;
63 struct oval_valuecxx . . $ oval_value# *valuecxx . . $ oval_entity#value.;
64 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xsi_nilcxx . . $ oval_entity#xsi_nil.; ///< @xsi:nil boolean attribute
65 };
66
67 struct oval_consume_varref_contextcxx . . $ oval_consume_varref_context# {
68 struct oval_definition_modelcxx . . $ oval_definition_model# *modelcxx . . $ oval_consume_varref_context#model.;
69 struct oval_variablecxx . . $ oval_variable# **variablecxx . . $ oval_consume_varref_context#variable.;
70 struct oval_valuecxx . . $ oval_value# **valuecxx . . $ oval_consume_varref_context#value.;
71 };
72
73 /* End of variable definitions
74 * */
75 /***************************************************************************/
76 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_entity_get_xsi_nilcxx . . $ oval_entity_get_xsi_nil(51d11e126a63b119).(const struct oval_entitycxx . . $ oval_entity# *entity);
77 static inline void oval_entity_set_xsi_nilcxx . . $ oval_entity_set_xsi_nil(6074ffc463154eba).(struct oval_entitycxx . . $ oval_entity# *entity, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xsi_nil);
78
79
80 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_entity_iterator_has_morecxx . . $ oval_entity_iterator_has_more(659a07d5a10072de).(struct oval_entity_iteratorcxx . . $ oval_entity_iterator# *oc_entity)
81 {
82 return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *)
83 oc_entity);
84 }
85
86 struct oval_entitycxx . . $ oval_entity# *oval_entity_iterator_nextcxx . . $ oval_entity_iterator_next(eb22d4c80b000f89).(struct oval_entity_iteratorcxx . . $ oval_entity_iterator#
87 *oc_entity)
88 {
89 return (struct oval_entitycxx . . $ oval_entity# *)
90 oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_entity);
91 }
92
93 void oval_entity_iterator_freecxx . . $ oval_entity_iterator_free(d7b45240159daa2e).(struct oval_entity_iteratorcxx . . $ oval_entity_iterator#
94 *oc_entity)
95 {
96 oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_entity);
97 }
98
99 char *oval_entity_get_namecxx . . $ oval_entity_get_name(29acad8590bc6a3f).(struct oval_entitycxx . . $ oval_entity# *entity)
100 {
101 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
102
103 return entity->namecxx . . $ oval_entity#name.;
104 }
105
106 oval_entity_type_tcxx . . $ oval_entity_type_t# oval_entity_get_typecxx . . $ oval_entity_get_type(c4fbc2dfb2f0b928).(struct oval_entitycxx . . $ oval_entity# * entity)
107 {
108 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
109
110 return entity->typecxx . . $ oval_entity#type.;
111 }
112
113 oval_datatype_tcxx . . $ oval_datatype_t# oval_entity_get_datatypecxx . . $ oval_entity_get_datatype(f8b1ce42a33ef434).(struct oval_entitycxx . . $ oval_entity# * entity)
114 {
115 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
116
117 return entity->datatypecxx . . $ oval_entity#datatype.;
118 }
119
120 oval_operation_tcxx . . $ oval_operation_t# oval_entity_get_operationcxx . . $ oval_entity_get_operation(7e30f6bdd49dced).(struct oval_entitycxx . . $ oval_entity# * entity)
121 {
122 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
123
124 return entity->operationcxx . . $ oval_entity#operation.;
125 }
126
127 int oval_entity_get_maskcxx . . $ oval_entity_get_mask(ec1837a8906f93c7).(struct oval_entitycxx . . $ oval_entity# *entity)
128 {
129 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
130
131 return entity->maskcxx . . $ oval_entity#mask.;
132 }
133
134 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_entity_get_xsi_nilcxx . . $ oval_entity_get_xsi_nil(51d11e126a63b119).(const struct oval_entitycxx . . $ oval_entity# *entity)
135 {
136 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
137 return entity->xsi_nilcxx . . $ oval_entity#xsi_nil.;
138 }
139
140 oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# oval_entity_get_varref_typecxx . . $ oval_entity_get_varref_type(ad657afef3bd7ab6).(struct oval_entitycxx . . $ oval_entity# * entity)
141 {
142 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
143
144 return entity->varref_typecxx . . $ oval_entity#varref_type.;
145 }
146
147 struct oval_variablecxx . . $ oval_variable# *oval_entity_get_variablecxx . . $ oval_entity_get_variable(fe3169ea470c913).(struct oval_entitycxx . . $ oval_entity# *entity)
148 {
149 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
150
151 return entity->variablecxx . . $ oval_entity#variable.;
152 }
153
154 struct oval_valuecxx . . $ oval_value# *oval_entity_get_valuecxx . . $ oval_entity_get_value(eeaa91aa0aedface).(struct oval_entitycxx . . $ oval_entity# *entity)
155 {
156 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
157
158 return entity->valuecxx . . $ oval_entity#value.;
159 }
160
161 struct oval_entitycxx . . $ oval_entity# *oval_entity_newcxx . . $ oval_entity_new(545e68612c5b020e).(struct oval_definition_modelcxx . . $ oval_definition_model# *model)
162 {
163 struct oval_entitycxx . . $ oval_entity# *entity = (struct oval_entitycxx . . $ oval_entity# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct oval_entitycxx . . $ oval_entity#));
164 if (entity == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
165 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
166
167 entity->datatypecxx . . $ oval_entity#datatype. = OVAL_DATATYPE_UNKNOWNcxx . . $ OVAL_DATATYPE_UNKNOWN.;
168 entity->maskcxx . . $ oval_entity#mask. = 0;
169 entity->xsi_nilcxx . . $ oval_entity#xsi_nil. = 0;
170 entity->operationcxx . . $ oval_entity#operation. = OVAL_OPERATION_UNKNOWNcxx . . $ OVAL_OPERATION_UNKNOWN.;
171 entity->typecxx . . $ oval_entity#type. = OVAL_ENTITY_TYPE_UNKNOWNcxx . . $ OVAL_ENTITY_TYPE_UNKNOWN.;
172 entity->namecxx . . $ oval_entity#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
173 entity->valuecxx . . $ oval_entity#value. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
174 entity->variablecxx . . $ oval_entity#variable. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
175 entity->modelcxx . . $ oval_entity#model. = model;
176 return entity;
177 }
178
179 struct oval_entitycxx . . $ oval_entity# *oval_entity_clonecxx . . $ oval_entity_clone(1af5ab030ffd9ac7).(struct oval_definition_modelcxx . . $ oval_definition_model# *new_model, struct oval_entitycxx . . $ oval_entity# *old_entity) {
180 struct oval_entitycxx . . $ oval_entity# *new_entity = oval_entity_newcxx . . $ oval_entity_new(545e68612c5b020e).(new_model);
181 oval_datatype_tcxx . . $ oval_datatype_t# datatype = oval_entity_get_datatypecxx . . $ oval_entity_get_datatype(f8b1ce42a33ef434).(old_entity);
182 oval_entity_set_datatypecxx . . $ oval_entity_set_datatype(aa45169678b22436).(new_entity, datatype);
183 int mask = oval_entity_get_maskcxx . . $ oval_entity_get_mask(ec1837a8906f93c7).(old_entity);
184 oval_entity_set_maskcxx . . $ oval_entity_set_mask(b9910cd71475dc77).(new_entity, mask);
185 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xsi_nil = oval_entity_get_xsi_nilcxx . . $ oval_entity_get_xsi_nil(51d11e126a63b119).(old_entity);
186 oval_entity_set_xsi_nilcxx . . $ oval_entity_set_xsi_nil(6074ffc463154eba).(new_entity, xsi_nil);
187 char *name = oval_entity_get_namecxx . . $ oval_entity_get_name(29acad8590bc6a3f).(old_entity);
188 oval_entity_set_namecxx . . $ oval_entity_set_name(660056fec04b8436).(new_entity, name);
189 oval_operation_tcxx . . $ oval_operation_t# operation = oval_entity_get_operationcxx . . $ oval_entity_get_operation(7e30f6bdd49dced).(old_entity);
190 oval_entity_set_operationcxx . . $ oval_entity_set_operation(9c0fa0f2b1346523).(new_entity, operation);
191 oval_entity_type_tcxx . . $ oval_entity_type_t# type = oval_entity_get_typecxx . . $ oval_entity_get_type(c4fbc2dfb2f0b928).(old_entity);
192 oval_entity_set_typecxx . . $ oval_entity_set_type(ce86c4544c5c0cf2).(new_entity, type);
193 struct oval_valuecxx . . $ oval_value# *value = oval_entity_get_valuecxx . . $ oval_entity_get_value(eeaa91aa0aedface).(old_entity);
194 if (value) {
195 oval_entity_set_valuecxx . . $ oval_entity_set_value(9c237f750e0e84b).(new_entity, oval_value_clonecxx . . $ oval_value_clone(5de282da9e151d11).(value));
196 }
197 struct oval_variablecxx . . $ oval_variable# *old_variable = oval_entity_get_variablecxx . . $ oval_entity_get_variable(fe3169ea470c913).(old_entity);
198 if (old_variable) {
199 oval_entity_set_variablecxx . . $ oval_entity_set_variable(4438457f93ca187f).(new_entity, oval_variable_clonecxx . . $ oval_variable_clone(f12623c0add04796).(new_model, old_variable));
200 }
201 oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# reftype = oval_entity_get_varref_typecxx . . $ oval_entity_get_varref_type(ad657afef3bd7ab6).(old_entity);
202 oval_entity_set_varref_typecxx . . $ oval_entity_set_varref_type(143231e98d2dcd5d).(new_entity, reftype);
203 return new_entity;
204 }
205
206 void oval_entity_freecxx . . $ oval_entity_free(b7cc62b9e2b9f845).(struct oval_entitycxx . . $ oval_entity# *entity)
207 {
208 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
209
210 if (entity->valuecxx . . $ oval_entity#value. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
211 oval_value_freecxx . . $ oval_value_free(d25d962808f14280).(entity->valuecxx . . $ oval_entity#value.);
212 if (entity->namecxx . . $ oval_entity#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
213 freecxx . . $ free(5d22bdacc48458e8).(entity->namecxx . . $ oval_entity#name.);
214
215 entity->namecxx . . $ oval_entity#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
216 entity->valuecxx . . $ oval_entity#value. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
217 entity->variablecxx . . $ oval_entity#variable. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
218 freecxx . . $ free(5d22bdacc48458e8).(entity);
219 }
220
221 void oval_entity_set_typecxx . . $ oval_entity_set_type(ce86c4544c5c0cf2).(struct oval_entitycxx . . $ oval_entity# *entity, oval_entity_type_tcxx . . $ oval_entity_type_t# type)
222 {
223 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
224 entity->typecxx . . $ oval_entity#type. = type;
225 }
226
227 void oval_entity_set_datatypecxx . . $ oval_entity_set_datatype(aa45169678b22436).(struct oval_entitycxx . . $ oval_entity# *entity, oval_datatype_tcxx . . $ oval_datatype_t# datatype)
228 {
229 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
230 entity->datatypecxx . . $ oval_entity#datatype. = datatype;
231 }
232
233 void oval_entity_set_operationcxx . . $ oval_entity_set_operation(9c0fa0f2b1346523).(struct oval_entitycxx . . $ oval_entity# *entity, oval_operation_tcxx . . $ oval_operation_t# operation)
234 {
235 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
236 entity->operationcxx . . $ oval_entity#operation. = operation;
237 }
238
239 void oval_entity_set_maskcxx . . $ oval_entity_set_mask(b9910cd71475dc77).(struct oval_entitycxx . . $ oval_entity# *entity, int mask)
240 {
241 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
242 entity->maskcxx . . $ oval_entity#mask. = mask;
243 }
244
245 static inline void oval_entity_set_xsi_nilcxx . . $ oval_entity_set_xsi_nil(6074ffc463154eba).(struct oval_entitycxx . . $ oval_entity# *entity, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! xsi_nil)
246 {
247 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
248 entity->xsi_nilcxx . . $ oval_entity#xsi_nil. = xsi_nil;
249 }
250
251 void oval_entity_set_varref_typecxx . . $ oval_entity_set_varref_type(143231e98d2dcd5d).(struct oval_entitycxx . . $ oval_entity# *entity, oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# type)
252 {
253 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
254 entity->varref_typecxx . . $ oval_entity#varref_type. = type;
255 }
256
257 void oval_entity_set_variablecxx . . $ oval_entity_set_variable(4438457f93ca187f).(struct oval_entitycxx . . $ oval_entity# *entity, struct oval_variablecxx . . $ oval_variable# *variable)
258 {
259 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
260 entity->variablecxx . . $ oval_entity#variable. = variable;
261 }
262
263 void oval_entity_set_valuecxx . . $ oval_entity_set_value(9c237f750e0e84b).(struct oval_entitycxx . . $ oval_entity# *entity, struct oval_valuecxx . . $ oval_value# *value)
264 {
265 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
266 entity->valuecxx . . $ oval_entity#value. = value;
267 }
268
269 void oval_entity_set_namecxx . . $ oval_entity_set_name(660056fec04b8436).(struct oval_entitycxx . . $ oval_entity# *entity, char *name)
270 {
271 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(entity);
272 if (entity->namecxx . . $ oval_entity#name. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
273 freecxx . . $ free(5d22bdacc48458e8).(entity->namecxx . . $ oval_entity#name.);
274 entity->namecxx . . $ oval_entity#name. = (name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! : oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(name);
275 }
276
277 static void oval_consume_varrefcxx . . $ oval_consume_varref(75961c4613ebf8f5).(char *varref, void *user)
278 {
279
280 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(user);
281
282 struct oval_consume_varref_contextcxx . . $ oval_consume_varref_context# *ctx = user;
283 *(ctx->variablecxx . . $ oval_consume_varref_context#variable.) = oval_definition_model_get_new_variablecxx . . $ oval_definition_model_get_new_variable(d0b65e206dc01f0d).((struct oval_definition_modelcxx . . $ oval_definition_model# *)ctx->modelcxx . . $ oval_consume_varref_context#model., varref, OVAL_VARIABLE_UNKNOWNcxx . . $ OVAL_VARIABLE_UNKNOWN.);
284 *(ctx->valuecxx . . $ oval_consume_varref_context#value.) = oval_value_newcxx . . $ oval_value_new(c58b1d972ef552d6).(OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., varref);
285 }
286
287 static void oval_consume_valuecxx . . $ oval_consume_value(4ed62f63db8a189a).(struct oval_valuecxx . . $ oval_value# *use_value, void *value)
288 {
289
290 *(struct oval_valuecxx . . $ oval_value# **)value = use_value;
291 }
292
293 //typedef void (*oval_entity_consumer)(struct oval_entity_node*, void*);
294 int oval_entity_parse_tagcxx . . $ oval_entity_parse_tag(29f485c9b2aa6ded).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader,
295 struct oval_parser_contextcxx . . $ oval_parser_context# *context, oscap_consumer_funccxx . . $ oscap_consumer_func# consumer, void *user)
296 {
297 __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(context);
298
299 struct oval_entitycxx . . $ oval_entity# *entity = oval_entity_newcxx . . $ oval_entity_new(545e68612c5b020e).(context->definition_modelcxx . . $ oval_parser_context#definition_model.);
300 int return_code = 0;
301 oval_datatype_tcxx . . $ oval_datatype_t# datatype = oval_datatype_parsecxx . . $ oval_datatype_parse(439a79c16bdf367b).(reader, "datatype", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING.);
302 oval_operation_tcxx . . $ oval_operation_t# operation = oval_operation_parsecxx . . $ oval_operation_parse(a65696f3feb28be6).(reader, "operation", OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.);
303 int mask = oval_parser_boolean_attributecxx . . $ oval_parser_boolean_attribute(a53adaee35698733).(reader, "mask", 0);
304
305 char *nil_attr = (char *) xmlTextReaderGetAttributeNscxx . . $ xmlTextReaderGetAttributeNs(21dfd50d05bdcb5f).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "nil", OSCAP_XMLNS_XSIcxx . . $ `src/common/elements.h:37:9`!);
306 int xsi_nil = oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(nil_attr, "true") != 0;
307 xmlFreecxx . . $ xmlFree.(nil_attr);
308
309 oval_entity_type_tcxx . . $ oval_entity_type_t# type = OVAL_ENTITY_TYPE_UNKNOWNcxx . . $ OVAL_ENTITY_TYPE_UNKNOWN.;
310 //The value of the type field vs. the complexity of extracting type is arguable
311 char *varref = (char *)xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "var_ref");
312 struct oval_valuecxx . . $ oval_value# *value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
313 struct oval_variablecxx . . $ oval_variable# *variable = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
314 char *name = (char *)xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader);
315 oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# varref_type;
316 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(name, "var_ref") == 0) { //special case for <var_ref>
317 if (varref == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
318 struct oval_definition_modelcxx . . $ oval_definition_model# *model = context->definition_modelcxx . . $ oval_parser_context#definition_model.;
319 varref_type = OVAL_ENTITY_VARREF_ELEMENTcxx . . $ OVAL_ENTITY_VARREF_ELEMENT.;
320 struct oval_consume_varref_contextcxx . . $ oval_consume_varref_context# ctx = {.model = model, .variable = &variable, .value = &value};
321 return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oval_consume_varrefcxx . . $ oval_consume_varref(75961c4613ebf8f5)., &ctx);
322 } else {
323 varref_type = OVAL_ENTITY_VARREF_ATTRIBUTEcxx . . $ OVAL_ENTITY_VARREF_ATTRIBUTE.;
324 struct oval_definition_modelcxx . . $ oval_definition_model# *model = context->definition_modelcxx . . $ oval_parser_context#definition_model.;
325 oval_schema_version_tcxx . . $ oval_schema_version_t# version = oval_definition_model_get_core_schema_versioncxx . . $ oval_definition_model_get_core_schema_version(5e2dc48a93a33b7c).(model);
326 if (oval_schema_version_cmpcxx . . $ oval_schema_version_cmp(b4d0c2bfb97f274f).(version, OVAL_SCHEMA_VERSIONcxx . . $ `src/OVAL/public/oval_schema_version.h:39:9`!(5.6)) > 0) {
327 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OVALcxx . . $ `src/common/public/oscap_error.h:61:9`!, "The var_ref attribute for the var_ref entity "
328 "of a variable_object is prohibited since OVAL 5.6. Use plain "
329 "var_ref instead.");
330 }
331 variable = oval_definition_model_get_variablecxx . . $ oval_definition_model_get_variable(6c0310206537dd28).(model, varref);
332 if (variable == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
333 oscap_seterrcxx . . $ `src/common/_error.h:52:9`!(OSCAP_EFAMILY_OVALcxx . . $ `src/common/public/oscap_error.h:61:9`!,
334 "Could not found variable '%s' referenced by var_ref element.", varref);
335 return_code = -1;
336 } else {
337 freecxx . . $ free(5d22bdacc48458e8).(varref);
338 varref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
339 value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
340 }
341 }
342 } else if (varref == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
343 variable = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
344 varref_type = OVAL_ENTITY_VARREF_NONEcxx . . $ OVAL_ENTITY_VARREF_NONE.;
345 if (datatype == OVAL_DATATYPE_RECORDcxx . . $ OVAL_DATATYPE_RECORD.) {
346 value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
347 } else {
348 if (xsi_nil)
349 value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
350 else
351 return_code = oval_value_parse_tagcxx . . $ oval_value_parse_tag(24b85e39d8efe8a).(reader, context, &oval_consume_valuecxx . . $ oval_consume_value(4ed62f63db8a189a)., &value);
352 }
353 } else {
354 struct oval_definition_modelcxx . . $ oval_definition_model# *model = context->definition_modelcxx . . $ oval_parser_context#definition_model.;
355 variable = oval_definition_model_get_new_variablecxx . . $ oval_definition_model_get_new_variable(d0b65e206dc01f0d).(model, varref, OVAL_VARIABLE_UNKNOWNcxx . . $ OVAL_VARIABLE_UNKNOWN.);
356 varref_type = OVAL_ENTITY_VARREF_ATTRIBUTEcxx . . $ OVAL_ENTITY_VARREF_ATTRIBUTE.;
357 value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
358 freecxx . . $ free(5d22bdacc48458e8).(varref);
359 varref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
360 }
361 oval_entity_set_namecxx . . $ oval_entity_set_name(660056fec04b8436).(entity, name);
362 oval_entity_set_typecxx . . $ oval_entity_set_type(ce86c4544c5c0cf2).(entity, type);
363 oval_entity_set_datatypecxx . . $ oval_entity_set_datatype(aa45169678b22436).(entity, datatype);
364 oval_entity_set_operationcxx . . $ oval_entity_set_operation(9c0fa0f2b1346523).(entity, operation);
365 oval_entity_set_maskcxx . . $ oval_entity_set_mask(b9910cd71475dc77).(entity, mask);
366 oval_entity_set_varref_typecxx . . $ oval_entity_set_varref_type(143231e98d2dcd5d).(entity, varref_type);
367 oval_entity_set_variablecxx . . $ oval_entity_set_variable(4438457f93ca187f).(entity, variable);
368 oval_entity_set_valuecxx . . $ oval_entity_set_value(9c237f750e0e84b).(entity, value);
369 oval_entity_set_xsi_nilcxx . . $ oval_entity_set_xsi_nil(6074ffc463154eba).(entity, xsi_nil);
370 (*consumer) (entity, user);
371
372 if (return_code != 0) {
373 dWcxx . . $ `src/common/debug_priv.h:62:9`!("Parsing of <%s> terminated by an error at line %d.", name, xmlTextReaderGetParserLineNumber(reader));
374 }
375
376 freecxx . . $ free(5d22bdacc48458e8).(name);
377 return return_code;
378 }
379
380 xmlNodecxx . . $ xmlNode# *oval_entity_to_domcxx . . $ oval_entity_to_dom(e76be2c7a3117d53).(struct oval_entitycxx . . $ oval_entity# *entity, xmlDoccxx . . $ xmlDoc# * doc, xmlNodecxx . . $ xmlNode# * parent) {
381
382 xmlNsPtrcxx . . $ xmlNsPtr# ent_ns = parent->nscxx . . $ _xmlNode#ns.;
383 xmlNodePtrcxx . . $ xmlNodePtr# root_node = xmlDocGetRootElementcxx . . $ xmlDocGetRootElement(53aa9a676bd496f2).(doc);
384
385 xmlNodecxx . . $ xmlNode# *entity_node = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
386 char *content = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
387
388 struct oval_variablecxx . . $ oval_variable# *variable = oval_entity_get_variablecxx . . $ oval_entity_get_variable(fe3169ea470c913).(entity);
389 oval_entity_varref_type_tcxx . . $ oval_entity_varref_type_t# vtype = oval_entity_get_varref_typecxx . . $ oval_entity_get_varref_type(ad657afef3bd7ab6).(entity);
390 struct oval_valuecxx . . $ oval_value# *value = oval_entity_get_valuecxx . . $ oval_entity_get_value(eeaa91aa0aedface).(entity);
391
392 if (vtype == OVAL_ENTITY_VARREF_ELEMENTcxx . . $ OVAL_ENTITY_VARREF_ELEMENT.) {
393 content = oval_variable_get_idcxx . . $ oval_variable_get_id(341a3c7e6ea3818b).(variable);
394 } else if (value) {
395 content = oval_value_get_textcxx . . $ oval_value_get_text(cab4e37bbd1656d5).(value);
396 }
397
398 char *tagname = oval_entity_get_namecxx . . $ oval_entity_get_name(29acad8590bc6a3f).(entity);
399 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! mask = oval_entity_get_maskcxx . . $ oval_entity_get_mask(ec1837a8906f93c7).(entity);
400
401 /* omit the value and operation used for testing in oval_results if mask=true */
402 /* Omit it only for older versions of OVAL than 5.10 */
403 oval_schema_version_tcxx . . $ oval_schema_version_t# oval_version = oval_definition_model_get_core_schema_versioncxx . . $ oval_definition_model_get_core_schema_version(5e2dc48a93a33b7c).(entity->modelcxx . . $ oval_entity#model.);
404 if (oval_schema_version_cmpcxx . . $ oval_schema_version_cmp(b4d0c2bfb97f274f).(oval_version, OVAL_SCHEMA_VERSIONcxx . . $ `src/OVAL/public/oval_schema_version.h:39:9`!(5.10)) < 0 &&
405 mask && !xmlStrcmpcxx . . $ xmlStrcmp(e46526da1a64e2fc).(root_node->namecxx . . $ _xmlNode#name., BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! OVAL_ROOT_ELM_RESULTScxx . . $ `src/OVAL/oval_parser_impl.h:40:9`!)) {
406 entity_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(parent, ent_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! tagname, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "");
407 } else {
408 entity_node = xmlNewTextChildcxx . . $ xmlNewTextChild(4c74f4d7754e7bc8).(parent, ent_ns, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! tagname, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! content);
409 oval_operation_tcxx . . $ oval_operation_t# operation = oval_entity_get_operationcxx . . $ oval_entity_get_operation(7e30f6bdd49dced).(entity);
410 if (operation != OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.)
411 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(entity_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "operation", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_operation_get_textcxx . . $ oval_operation_get_text(bf6188043a942ccf).(operation));
412 if (oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(content, "") && oval_entity_get_xsi_nilcxx . . $ oval_entity_get_xsi_nil(51d11e126a63b119).(entity)) {
413 // Export @xsi:nil="true" only if it was imported and the content is still empty
414 xmlNewNsPropcxx . . $ xmlNewNsProp(9b3cf13d34b7936f).(entity_node, lookup_xsi_nscxx . . $ lookup_xsi_ns(3e517de3a327c4f9).(doc), BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "nil", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "true");
415 }
416 }
417
418 oval_datatype_tcxx . . $ oval_datatype_t# datatype = oval_entity_get_datatypecxx . . $ oval_entity_get_datatype(f8b1ce42a33ef434).(entity);
419 if (datatype != OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING.)
420 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(entity_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "datatype", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_datatype_get_textcxx . . $ oval_datatype_get_text(a950b89baeb79474).(datatype));
421 if (mask)
422 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(entity_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "mask", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "true");
423 if (vtype == OVAL_ENTITY_VARREF_ATTRIBUTEcxx . . $ OVAL_ENTITY_VARREF_ATTRIBUTE.)
424 xmlNewPropcxx . . $ xmlNewProp(6ee5a6130c40eb8b).(entity_node, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "var_ref", BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! oval_variable_get_idcxx . . $ oval_variable_get_id(341a3c7e6ea3818b).(variable));
425
426 return entity_node;
427 }