| 1 | /** |
| 2 | * @file oval_affected.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 "oval_definitions_impl.h"cxx . . $ `<file>/src/OVAL/oval_definitions_impl.h`/ |
| 39 | #include "adt/oval_collection_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_collection_impl.h`/ |
| 40 | #include "oval_parser_impl.h"cxx . . $ `<file>/src/OVAL/oval_parser_impl.h`/ |
| 41 | #include "adt/oval_string_map_impl.h"cxx . . $ `<file>/src/OVAL/adt/oval_string_map_impl.h`/ |
| 42 | |
| 43 | #include "common/util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 44 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 45 | #include "common/elements.h"cxx . . $ `<file>/src/common/elements.h`/ |
| 46 | #include "common/_error.h"cxx . . $ `<file>/src/common/_error.h`/ |
| 47 | |
| 48 | /***************************************************************************/ |
| 49 | /* Variable definitions |
| 50 | * */ |
| 51 | |
| 52 | typedef struct oval_affectedcxx . . $ oval_affected# { |
| 53 | struct oval_definition_modelcxx . . $ oval_definition_model# *modelcxx . . $ oval_affected#model.; |
| 54 | oval_affected_family_tcxx . . $ oval_affected_family_t# familycxx . . $ oval_affected#family.; |
| 55 | struct oval_collectioncxx . . $ oval_collection# *platformscxx . . $ oval_affected#platforms.; |
| 56 | struct oval_collectioncxx . . $ oval_collection# *productscxx . . $ oval_affected#products.; |
| 57 | } oval_affected_tcxx . . $ oval_affected_t#; |
| 58 | |
| 59 | static const struct oscap_string_mapcxx . . $ oscap_string_map# OVAL_ODAFAMILY_MAPcxx . . $ OVAL_ODAFAMILY_MAP.[] = { |
| 60 | {OVAL_AFCFML_CATOScxx . . $ OVAL_AFCFML_CATOS., "catos"}, |
| 61 | {OVAL_AFCFML_IOScxx . . $ OVAL_AFCFML_IOS., "ios"}, |
| 62 | {OVAL_AFCFML_MACOScxx . . $ OVAL_AFCFML_MACOS., "macos"}, |
| 63 | {OVAL_AFCFML_PIXOScxx . . $ OVAL_AFCFML_PIXOS., "pixos"}, |
| 64 | {OVAL_AFCFML_UNDEFINEDcxx . . $ OVAL_AFCFML_UNDEFINED., "undefined"}, |
| 65 | {OVAL_AFCFML_UNIXcxx . . $ OVAL_AFCFML_UNIX., "unix"}, |
| 66 | {OVAL_AFCFML_WINDOWScxx . . $ OVAL_AFCFML_WINDOWS., "windows"}, |
| 67 | // the "unknown" is not a valid OVAL family value, we use it internally |
| 68 | // when the supplied value is invalid |
| 69 | {OVAL_AFCFML_UNKNOWNcxx . . $ OVAL_AFCFML_UNKNOWN., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!} |
| 70 | }; |
| 71 | |
| 72 | /* End of variable definitions |
| 73 | * */ |
| 74 | /***************************************************************************/ |
| 75 | |
| 76 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! oval_affected_iterator_has_morecxx . . $ oval_affected_iterator_has_more(178424f7a96afe6c).(struct oval_affected_iteratorcxx . . $ oval_affected_iterator# *oc_affected) |
| 77 | { |
| 78 | return oval_collection_iterator_has_morecxx . . $ oval_collection_iterator_has_more(de0650ab9b639739).((struct oval_iteratorcxx . . $ oval_iterator# *) |
| 79 | oc_affected); |
| 80 | } |
| 81 | |
| 82 | struct oval_affectedcxx . . $ oval_affected# *oval_affected_iterator_nextcxx . . $ oval_affected_iterator_next(dc665843cb96a3b8).(struct oval_affected_iteratorcxx . . $ oval_affected_iterator# |
| 83 | *oc_affected) |
| 84 | { |
| 85 | return (struct oval_affectedcxx . . $ oval_affected# *) |
| 86 | oval_collection_iterator_nextcxx . . $ oval_collection_iterator_next(344074693c9690a9).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_affected); |
| 87 | } |
| 88 | |
| 89 | void oval_affected_iterator_freecxx . . $ oval_affected_iterator_free(909fa3115b79bd9f).(struct oval_affected_iteratorcxx . . $ oval_affected_iterator# |
| 90 | *oc_affected) |
| 91 | { |
| 92 | oval_collection_iterator_freecxx . . $ oval_collection_iterator_free(ee496816570b41f7).((struct oval_iteratorcxx . . $ oval_iterator# *)oc_affected); |
| 93 | } |
| 94 | |
| 95 | oval_affected_family_tcxx . . $ oval_affected_family_t# oval_affected_get_familycxx . . $ oval_affected_get_family(62b180de559e1e1b).(struct oval_affectedcxx . . $ oval_affected# *affected) |
| 96 | { |
| 97 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 98 | |
| 99 | return ((struct oval_affectedcxx . . $ oval_affected# *)affected)->familycxx . . $ oval_affected#family.; |
| 100 | } |
| 101 | |
| 102 | struct oval_string_iteratorcxx . . $ oval_string_iterator# *oval_affected_get_platformscxx . . $ oval_affected_get_platforms(7c544294b661c17f).(struct oval_affectedcxx . . $ oval_affected# *affected) |
| 103 | { |
| 104 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 105 | |
| 106 | return (struct oval_string_iteratorcxx . . $ oval_string_iterator# *) |
| 107 | oval_collection_iteratorcxx . . $ oval_collection_iterator(8bdeb6a25e21af3e).(affected->platformscxx . . $ oval_affected#platforms.); |
| 108 | } |
| 109 | |
| 110 | struct oval_string_iteratorcxx . . $ oval_string_iterator# *oval_affected_get_productscxx . . $ oval_affected_get_products(7c544294b661c17f).(struct oval_affectedcxx . . $ oval_affected# *affected) |
| 111 | { |
| 112 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 113 | |
| 114 | return (struct oval_string_iteratorcxx . . $ oval_string_iterator# *) |
| 115 | oval_collection_iteratorcxx . . $ oval_collection_iterator(8bdeb6a25e21af3e).(affected->productscxx . . $ oval_affected#products.); |
| 116 | } |
| 117 | |
| 118 | struct oval_affectedcxx . . $ oval_affected# *oval_affected_newcxx . . $ oval_affected_new(1d6ea0da5069637e).(struct oval_definition_modelcxx . . $ oval_definition_model# *model) |
| 119 | { |
| 120 | struct oval_affectedcxx . . $ oval_affected# *affected = (struct oval_affectedcxx . . $ oval_affected# *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(oval_affected_tcxx . . $ oval_affected_t#)); |
| 121 | if (affected == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 122 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 123 | |
| 124 | affected->modelcxx . . $ oval_affected#model. = model; |
| 125 | affected->familycxx . . $ oval_affected#family. = OVAL_AFCFML_UNKNOWNcxx . . $ OVAL_AFCFML_UNKNOWN.; |
| 126 | affected->platformscxx . . $ oval_affected#platforms. = oval_collection_newcxx . . $ oval_collection_new(18476da3f812812d).(); |
| 127 | affected->productscxx . . $ oval_affected#products. = oval_collection_newcxx . . $ oval_collection_new(18476da3f812812d).(); |
| 128 | return affected; |
| 129 | } |
| 130 | |
| 131 | struct oval_affectedcxx . . $ oval_affected# *oval_affected_clonecxx . . $ oval_affected_clone(135242d5b88f5372).(struct oval_definition_modelcxx . . $ oval_definition_model# *new_model, struct oval_affectedcxx . . $ oval_affected# *old_affected) |
| 132 | { |
| 133 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(old_affected); |
| 134 | |
| 135 | struct oval_affectedcxx . . $ oval_affected# *new_affected = oval_affected_newcxx . . $ oval_affected_new(1d6ea0da5069637e).(new_model); |
| 136 | |
| 137 | oval_affected_set_familycxx . . $ oval_affected_set_family(b8d344949b193245).(new_affected, old_affected->familycxx . . $ oval_affected#family.); |
| 138 | |
| 139 | struct oval_string_iteratorcxx . . $ oval_string_iterator# *platforms = oval_affected_get_platformscxx . . $ oval_affected_get_platforms(7c544294b661c17f).(old_affected); |
| 140 | while (oval_string_iterator_has_morecxx . . $ oval_string_iterator_has_more(41a15bd829ecb6dd).(platforms)) { |
| 141 | char *platform = oval_string_iterator_nextcxx . . $ oval_string_iterator_next(fc393b19611653f6).(platforms); |
| 142 | oval_affected_add_platformcxx . . $ oval_affected_add_platform(8ad127819eee389a).(new_affected, platform); |
| 143 | } |
| 144 | oval_string_iterator_freecxx . . $ oval_string_iterator_free(eccafcd0705f3c29).(platforms); |
| 145 | |
| 146 | struct oval_string_iteratorcxx . . $ oval_string_iterator# *products = oval_affected_get_productscxx . . $ oval_affected_get_products(7c544294b661c17f).(old_affected); |
| 147 | while (oval_string_iterator_has_morecxx . . $ oval_string_iterator_has_more(41a15bd829ecb6dd).(products)) { |
| 148 | char *product = oval_string_iterator_nextcxx . . $ oval_string_iterator_next(fc393b19611653f6).(products); |
| 149 | oval_affected_add_productcxx . . $ oval_affected_add_product(8ad127819eee389a).(new_affected, product); |
| 150 | } |
| 151 | oval_string_iterator_freecxx . . $ oval_string_iterator_free(eccafcd0705f3c29).(products); |
| 152 | |
| 153 | return new_affected; |
| 154 | } |
| 155 | |
| 156 | void oval_affected_freecxx . . $ oval_affected_free(cb0e034c0e2ba1f5).(struct oval_affectedcxx . . $ oval_affected# *affected) |
| 157 | { |
| 158 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 159 | |
| 160 | oval_collection_free_itemscxx . . $ oval_collection_free_items(637ec69504f927f1).(affected->platformscxx . . $ oval_affected#platforms., (oscap_destruct_funccxx . . $ oscap_destruct_func#) freecxx . . $ free(5d22bdacc48458e8).); |
| 161 | affected->platformscxx . . $ oval_affected#platforms. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 162 | oval_collection_free_itemscxx . . $ oval_collection_free_items(637ec69504f927f1).(affected->productscxx . . $ oval_affected#products., (oscap_destruct_funccxx . . $ oscap_destruct_func#) freecxx . . $ free(5d22bdacc48458e8).); |
| 163 | affected->productscxx . . $ oval_affected#products. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 164 | freecxx . . $ free(5d22bdacc48458e8).(affected); |
| 165 | } |
| 166 | |
| 167 | void oval_affected_set_familycxx . . $ oval_affected_set_family(b8d344949b193245).(struct oval_affectedcxx . . $ oval_affected# *affected, oval_affected_family_tcxx . . $ oval_affected_family_t# family) |
| 168 | { |
| 169 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 170 | |
| 171 | affected->familycxx . . $ oval_affected#family. = family; |
| 172 | } |
| 173 | |
| 174 | void oval_affected_add_platformcxx . . $ oval_affected_add_platform(8ad127819eee389a).(struct oval_affectedcxx . . $ oval_affected# *affected, char *platform) |
| 175 | { |
| 176 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 177 | |
| 178 | oval_collection_addcxx . . $ oval_collection_add(3c6bf54730c0284).(affected->platformscxx . . $ oval_affected#platforms., (void *)oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(platform)); |
| 179 | } |
| 180 | |
| 181 | void oval_affected_add_productcxx . . $ oval_affected_add_product(8ad127819eee389a).(struct oval_affectedcxx . . $ oval_affected# *affected, char *product) |
| 182 | { |
| 183 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(affected); |
| 184 | |
| 185 | oval_collection_addcxx . . $ oval_collection_add(3c6bf54730c0284).(affected->productscxx . . $ oval_affected#products., (void *)oscap_strdupcxx . . $ oscap_strdup(a8b8e32347182212).(product)); |
| 186 | } |
| 187 | |
| 188 | static oval_affected_family_tcxx . . $ oval_affected_family_t# _odafamilycxx . . $ _odafamily(d051cd5baa4c7eb5).(char *family) |
| 189 | { |
| 190 | return oscap_string_to_enumcxx . . $ oscap_string_to_enum(851d6ce10579b7d8).(OVAL_ODAFAMILY_MAPcxx . . $ OVAL_ODAFAMILY_MAP., family); |
| 191 | } |
| 192 | |
| 193 | const char *oval_affected_family_get_textcxx . . $ oval_affected_family_get_text(a4f5ae4cfe4b2931).(oval_affected_family_tcxx . . $ oval_affected_family_t# family) |
| 194 | { |
| 195 | return oscap_enum_to_stringcxx . . $ oscap_enum_to_string(64165c519d473d40).(OVAL_ODAFAMILY_MAPcxx . . $ OVAL_ODAFAMILY_MAP., family); |
| 196 | } |
| 197 | |
| 198 | static int _oval_affected_parse_tagcxx . . $ _oval_affected_parse_tag(cf369959597901d1).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context, void *user) |
| 199 | { |
| 200 | struct oval_affectedcxx . . $ oval_affected# *affected = (struct oval_affectedcxx . . $ oval_affected# *)user; |
| 201 | int return_code; |
| 202 | xmlCharcxx . . $ xmlChar# *tagname = xmlTextReaderLocalNamecxx . . $ xmlTextReaderLocalName(3322afb275581432).(reader); |
| 203 | //xmlChar *namespace = xmlTextReaderNamespaceUri(reader); |
| 204 | |
| 205 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((char *)tagname, "platform") == 0) { |
| 206 | char *platform = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 207 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oscap_text_consumercxx . . $ oscap_text_consumer(75961c4613ebf8f5)., &platform); |
| 208 | if (platform != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 209 | oval_affected_add_platformcxx . . $ oval_affected_add_platform(8ad127819eee389a).(affected, platform); |
| 210 | freecxx . . $ free(5d22bdacc48458e8).(platform); |
| 211 | } |
| 212 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).((char *)tagname, "product") == 0) { |
| 213 | char *product = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 214 | return_code = oscap_parser_text_valuecxx . . $ oscap_parser_text_value(23cd2d9646b6359b).(reader, &oscap_text_consumercxx . . $ oscap_text_consumer(75961c4613ebf8f5)., &product); |
| 215 | if (product != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 216 | oval_affected_add_productcxx . . $ oval_affected_add_product(8ad127819eee389a).(affected, product); |
| 217 | freecxx . . $ free(5d22bdacc48458e8).(product); |
| 218 | } |
| 219 | } else { |
| 220 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Skipping tag: %s", tagname); |
| 221 | return_code = oval_parser_skip_tagcxx . . $ oval_parser_skip_tag(b61d4daae99e998a).(reader, context); |
| 222 | } |
| 223 | freecxx . . $ free(5d22bdacc48458e8).(tagname); |
| 224 | return return_code; |
| 225 | } |
| 226 | |
| 227 | int oval_affected_parse_tagcxx . . $ oval_affected_parse_tag(38ff2ed3a5524b93).(xmlTextReaderPtrcxx . . $ xmlTextReaderPtr# reader, struct oval_parser_contextcxx . . $ oval_parser_context# *context, oval_affected_consumercxx . . $ oval_affected_consumer# consumer, void *user) |
| 228 | { |
| 229 | __attribute__nonnull__cxx . . $ `src/common/util.h:39:9`!(context); |
| 230 | |
| 231 | struct oval_affectedcxx . . $ oval_affected# *affected = oval_affected_newcxx . . $ oval_affected_new(1d6ea0da5069637e).(context->definition_modelcxx . . $ oval_parser_context#definition_model.); |
| 232 | char *family = (char *)xmlTextReaderGetAttributecxx . . $ xmlTextReaderGetAttribute(6d056300a6ef2116).(reader, BAD_CASTcxx . . $ `<external>/11592416788776295748/xmlstring.h:34:9`! "family"); |
| 233 | oval_affected_set_familycxx . . $ oval_affected_set_family(b8d344949b193245).(affected, _odafamilycxx . . $ _odafamily(d051cd5baa4c7eb5).(family)); |
| 234 | freecxx . . $ free(5d22bdacc48458e8).(family); |
| 235 | (*consumer) (affected, user); |
| 236 | return oval_parser_parse_tagcxx . . $ oval_parser_parse_tag(4eaaf867ce26f59b).(reader, context, &_oval_affected_parse_tagcxx . . $ _oval_affected_parse_tag(cf369959597901d1)., affected); |
| 237 | } |
| 238 |