diff -u -r a/src/CPE/cpedict.c b/src/CPE/cpedict.c --- a/src/CPE/cpedict.c 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpedict.c 2009-12-09 11:54:00 -0500 @@ -28,15 +28,19 @@ * Lukas Kuklinek */ +#include + #include "public/cpedict.h" #include "cpedict_priv.h" #include "../common/list.h" #include "../common/util.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + struct cpe_dict_model * cpe_dict_model_import(const struct oscap_import_source * source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) if (oscap_import_source_get_filename(source) == NULL) return NULL; @@ -49,8 +53,8 @@ void cpe_dict_model_export(const struct cpe_dict_model * dict, const struct oscap_export_target * target) { - __attribute__nonnull__(dict); - __attribute__nonnull__(target); + __attribute__nonnull__(dict) + __attribute__nonnull__(target) if (oscap_export_target_get_filename(target) == NULL) return; @@ -60,8 +64,8 @@ bool cpe_name_match_dict(struct cpe_name * cpe, struct cpe_dict_model * dict) { - __attribute__nonnull__(cpe); - __attribute__nonnull__(dict); + __attribute__nonnull__(cpe) + __attribute__nonnull__(dict) if (cpe == NULL || dict == NULL) return false; @@ -85,8 +89,8 @@ bool cpe_name_match_dict_str(const char *cpestr, struct cpe_dict_model * dict) { - __attribute__nonnull__(cpestr); - __attribute__nonnull__(dict); + __attribute__nonnull__(cpestr) + __attribute__nonnull__(dict) bool ret; if (cpestr == NULL) diff -u -r a/src/CPE/cpedict_priv.c b/src/CPE/cpedict_priv.c --- a/src/CPE/cpedict_priv.c 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpedict_priv.c 2009-12-09 11:55:41 -0500 @@ -32,17 +32,20 @@ #include #include "cpedict_priv.h" -#include "cpedict.h" -#include "cpeuri.h" +#include "public/cpedict.h" +#include "public/cpeuri.h" // for functions isspace #include // for functins memset, strcpy #include +#include #include "../common/list.h" #include "../common/elements.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /***************************************************************************/ /* Variable definitions * */ @@ -299,8 +302,8 @@ * */ static bool cpe_dict_model_add_item(struct cpe_dict_model * dict, struct cpe_item * item) { - __attribute__nonnull__(dict); - __attribute__nonnull__(item); + __attribute__nonnull__(dict) + __attribute__nonnull__(item) if (dict == NULL || item == NULL) return false; @@ -331,7 +334,7 @@ * */ static int xmlTextReaderNextElement(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) int ret; do { @@ -344,7 +347,7 @@ static bool cpe_validate_xml(const char * filename) { - __attribute__nonnull__(filename); + __attribute__nonnull__(filename) xmlParserCtxtPtr ctxt; /* the parser context */ xmlDocPtr doc; /* the resulting document tree */ @@ -622,7 +625,7 @@ */ struct cpe_dict_model * cpe_dict_model_parse_xml(const struct oscap_import_source * source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) xmlTextReaderPtr reader; struct cpe_dict_model *dict = NULL; @@ -643,7 +646,7 @@ struct cpe_dict_model * cpe_dict_model_parse(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) struct cpe_dict_model *ret = NULL; struct cpe_item *item = NULL; @@ -719,7 +722,7 @@ struct cpe_generator * cpe_generator_parse(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) struct cpe_generator *ret = NULL; @@ -784,7 +787,7 @@ struct cpe_reference *ref = NULL; char *data; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) if (!xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_CPE_ITEM_STR) && xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) { @@ -902,7 +905,7 @@ struct cpe_check *ret; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) if (xmlStrcmp (xmlTextReaderConstLocalName(reader), TAG_CHECK_STR) != 0) return NULL; @@ -924,7 +927,7 @@ struct cpe_reference *ret; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) if (xmlStrcmp (xmlTextReaderConstLocalName(reader), TAG_REFERENCE_STR) != 0) return NULL; @@ -953,7 +956,7 @@ struct cpe_language *language = NULL; char *data; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) if (xmlStrcmp (xmlTextReaderConstLocalName(reader), TAG_VENDOR_STR) != 0) return NULL; @@ -1060,8 +1063,8 @@ */ void cpe_dict_model_export_xml(const struct cpe_dict_model * dict, const struct oscap_export_target * target) { - __attribute__nonnull__(dict); - __attribute__nonnull__(target); + __attribute__nonnull__(dict) + __attribute__nonnull__(target) // TODO: add macro to check return value from xmlTextWriter* functions xmlTextWriterPtr writer; @@ -1085,8 +1088,8 @@ void cpe_dict_export(const struct cpe_dict_model * dict, xmlTextWriterPtr writer) { - __attribute__nonnull__(dict); - __attribute__nonnull__(writer); + __attribute__nonnull__(dict) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST dict->xml.namespace, TAG_CPE_LIST_STR, NULL); @@ -1113,8 +1116,8 @@ void cpe_generator_export(const struct cpe_generator * generator, xmlTextWriterPtr writer) { - __attribute__nonnull__(generator); - __attribute__nonnull__(writer); + __attribute__nonnull__(generator) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST generator->xml.namespace, TAG_GENERATOR_STR, NULL); if (generator->product_name != NULL) { @@ -1146,8 +1149,8 @@ char *temp; struct oscap_iterator *it;; - __attribute__nonnull__(item); - __attribute__nonnull__(writer); + __attribute__nonnull__(item) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST item->xml.namespace, TAG_CPE_ITEM_STR, NULL); if (item->name != NULL) { @@ -1210,8 +1213,8 @@ void cpe_vendor_export(const struct cpe_vendor * vendor, xmlTextWriterPtr writer) { - __attribute__nonnull__(vendor); - __attribute__nonnull__(writer); + __attribute__nonnull__(vendor) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST vendor->xml.namespace, TAG_VENDOR_STR, NULL); if (vendor->value != NULL) @@ -1230,8 +1233,8 @@ static void cpe_product_export(const struct cpe_product * product, xmlTextWriterPtr writer) { - __attribute__nonnull__(product); - __attribute__nonnull__(writer); + __attribute__nonnull__(product) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST product->xml.namespace, TAG_PRODUCT_STR, NULL); if (product->value != NULL) @@ -1248,8 +1251,8 @@ static void cpe_version_export(const struct cpe_version * version, xmlTextWriterPtr writer) { - __attribute__nonnull__(version); - __attribute__nonnull__(writer); + __attribute__nonnull__(version) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST version->xml.namespace, TAG_VERSION_STR, NULL); if (version->value != NULL) @@ -1265,8 +1268,8 @@ static void cpe_update_export(const struct cpe_update * update, xmlTextWriterPtr writer){ - __attribute__nonnull__(update); - __attribute__nonnull__(writer); + __attribute__nonnull__(update) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST update->xml.namespace, TAG_UPDATE_STR, NULL); if (update->value != NULL) @@ -1280,8 +1283,8 @@ } static void cpe_edition_export(const struct cpe_edition * edition, xmlTextWriterPtr writer){ - __attribute__nonnull__(edition); - __attribute__nonnull__(writer); + __attribute__nonnull__(edition) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST edition->xml.namespace, TAG_EDITION_STR, NULL); if (edition->value != NULL) @@ -1295,8 +1298,8 @@ } static void cpe_language_export(const struct cpe_language * language, xmlTextWriterPtr writer){ - __attribute__nonnull__(language); - __attribute__nonnull__(writer); + __attribute__nonnull__(language) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST language->xml.namespace, TAG_LANGUAGE_STR, NULL); if (language->value != NULL) @@ -1309,8 +1312,8 @@ static void cpe_note_export(const struct oscap_title * title, xmlTextWriterPtr writer) { - __attribute__nonnull__(title); - __attribute__nonnull__(writer); + __attribute__nonnull__(title) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST title->xml.namespace, TAG_NOTE_STR, NULL); if (title->xml.lang != NULL) @@ -1321,8 +1324,8 @@ } static void cpe_check_export(const struct cpe_check *check, xmlTextWriterPtr writer) { - __attribute__nonnull__(check); - __attribute__nonnull__(writer); + __attribute__nonnull__(check) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST check->xml.namespace, TAG_CHECK_STR, NULL); if (check->system != NULL) @@ -1335,8 +1338,8 @@ } static void cpe_reference_export(const struct cpe_reference * ref, xmlTextWriterPtr writer) { - __attribute__nonnull__(ref); - __attribute__nonnull__(writer); + __attribute__nonnull__(ref) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST ref->xml.namespace, TAG_REFERENCE_STR, NULL); if (ref->href != NULL) diff -u -r a/src/CPE/cpedict_priv.h b/src/CPE/cpedict_priv.h --- a/src/CPE/cpedict_priv.h 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpedict_priv.h 2009-11-30 11:03:02 -0500 @@ -45,7 +45,7 @@ #include #include -#include "cpeuri.h" +#include "../CPE/public/cpeuri.h" #include "../common/public/oscap.h" #include "../common/util.h" #include "../common/elements.h" diff -u -r a/src/CPE/cpelang.c b/src/CPE/cpelang.c --- a/src/CPE/cpelang.c 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpelang.c 2009-12-09 11:57:20 -0500 @@ -30,6 +30,7 @@ #include #include +#include #include "cpelang_priv.h" #include "public/cpelang.h" @@ -37,9 +38,11 @@ #include "../common/util.h" #include "../common/list.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + struct cpe_lang_model * cpe_lang_model_import(const struct oscap_import_source *source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) if (oscap_import_source_get_filename(source) == NULL) return NULL; @@ -52,8 +55,8 @@ void cpe_lang_model_export(const struct cpe_lang_model * spec, struct oscap_export_target * target) { - __attribute__nonnull__(spec); - __attribute__nonnull__(target); + __attribute__nonnull__(spec) + __attribute__nonnull__(target) if (oscap_export_target_get_filename(target) == NULL) return; @@ -70,8 +73,8 @@ static bool cpe_language_match_expr(struct cpe_name ** cpe, size_t n, const struct cpe_testexpr * expr) { - __attribute__nonnull__(cpe); - __attribute__nonnull__(expr); + __attribute__nonnull__(cpe) + __attribute__nonnull__(expr) struct cpe_testexpr *cur; bool ret; @@ -115,8 +118,8 @@ bool cpe_language_match_str(const char* cpe, const struct cpe_platform* platform) { - __attribute__nonnull__(cpe); - __attribute__nonnull__(platform); + __attribute__nonnull__(cpe) + __attribute__nonnull__(platform) struct cpe_name* cpe_; bool ret; diff -u -r a/src/CPE/cpelang_priv.c b/src/CPE/cpelang_priv.c --- a/src/CPE/cpelang_priv.c 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpelang_priv.c 2009-12-09 11:58:17 -0500 @@ -32,6 +32,7 @@ #include #include #include +#include #include "cpelang_priv.h" #include "public/cpelang.h" @@ -40,6 +41,8 @@ #include "../common/list.h" #include "../common/elements.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /***************************************************************************/ /* Variable definitions * */ @@ -124,7 +127,7 @@ */ static int xmlTextReaderNextElement(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) int ret; do { @@ -137,7 +140,7 @@ const struct cpe_testexpr * cpe_platform_get_expr(const struct cpe_platform *item) { - __attribute__nonnull__(item); + __attribute__nonnull__(item) if (item == NULL) return NULL; @@ -147,7 +150,7 @@ const struct cpe_testexpr * cpe_testexpr_get_next(const struct cpe_testexpr * expr) { - __attribute__nonnull__(expr); + __attribute__nonnull__(expr) return ++(expr); } @@ -226,7 +229,7 @@ static bool cpe_validate_xml(const char * filename) { - __attribute__nonnull__(filename); + __attribute__nonnull__(filename) xmlParserCtxtPtr ctxt; /* the parser context */ xmlDocPtr doc; /* the resulting document tree */ @@ -254,7 +257,7 @@ struct cpe_lang_model * cpe_lang_model_parse_xml(const struct oscap_import_source * source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) xmlTextReaderPtr reader; struct cpe_lang_model *ret = NULL; @@ -280,7 +283,7 @@ struct xml_metadata *xml = NULL; struct cpe_platform *platform = NULL; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) if (!xmlStrcmp(xmlTextReaderConstLocalName(reader), TAG_PLATFORM_SPEC_STR) && xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) { @@ -323,7 +326,7 @@ struct cpe_platform *ret; struct oscap_title *title; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) // allocate platform structure here ret = cpe_platform_new(); @@ -373,7 +376,7 @@ size_t elem_cnt = 0; struct cpe_testexpr * ret = NULL; - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) // allocation ret = cpe_testexpr_new(); @@ -459,8 +462,8 @@ char *string = NULL; - __attribute__nonnull__(reader); - __attribute__nonnull__(name); + __attribute__nonnull__(reader) + __attribute__nonnull__(name) // parse string element attributes here (like xml:lang) @@ -490,8 +493,8 @@ */ void cpe_lang_model_export_xml(const struct cpe_lang_model * spec, struct oscap_export_target * target) { - __attribute__nonnull__(spec); - __attribute__nonnull__(target); + __attribute__nonnull__(spec) + __attribute__nonnull__(target) // TODO: ad macro to check return value from xmlTextWriter* functions xmlTextWriterPtr writer; @@ -514,8 +517,8 @@ void cpe_lang_export(const struct cpe_lang_model * spec, xmlTextWriterPtr writer) { - __attribute__nonnull__(spec); - __attribute__nonnull__(writer); + __attribute__nonnull__(spec) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST spec->ns_prefix, TAG_PLATFORM_SPEC_STR, BAD_CAST spec->ns_href); @@ -532,8 +535,8 @@ void cpe_platform_export(const struct cpe_platform * platform, xmlTextWriterPtr writer) { - __attribute__nonnull__(platform); - __attribute__nonnull__(writer); + __attribute__nonnull__(platform) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST platform->xml.namespace, TAG_PLATFORM_STR, NULL); if (cpe_platform_get_id(platform) != NULL) @@ -548,7 +551,7 @@ void cpe_testexpr_export(struct cpe_testexpr expr, xmlTextWriterPtr writer) { - __attribute__nonnull__(writer); + __attribute__nonnull__(writer) if (expr.oper == CPE_LANG_OPER_HALT) return; diff -u -r a/src/CPE/cpelang_priv.h b/src/CPE/cpelang_priv.h --- a/src/CPE/cpelang_priv.h 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpelang_priv.h 2009-11-30 11:04:35 -0500 @@ -44,7 +44,7 @@ #include #include -#include "cpelang.h" +#include "../CPE/public/cpelang.h" #include "../common/util.h" #include "../common/list.h" #include "../common/elements.h" diff -u -r a/src/CPE/cpeuri.c b/src/CPE/cpeuri.c --- a/src/CPE/cpeuri.c 2009-12-11 11:40:26 -0500 +++ b/src/CPE/cpeuri.c 2009-12-09 11:59:28 -0500 @@ -34,10 +34,13 @@ #include #include #include +#include -#include "cpeuri.h" +#include "public/cpeuri.h" #include "../common/util.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + // enumeration of CPE URI fields (useful for indexing arrays) enum cpe_field_t { CPE_FIELD_TYPE, @@ -99,7 +102,7 @@ static int cpe_fields_num(const struct cpe_name *cpe) { - __attribute__nonnull__(cpe); + __attribute__nonnull__(cpe) if (cpe == NULL) return 0; int maxnum = 0; @@ -112,7 +115,7 @@ static const char *cpe_get_field(const struct cpe_name *cpe, int idx) { - __attribute__nonnull__(cpe); + __attribute__nonnull__(cpe) if (cpe == NULL) return NULL; @@ -131,8 +134,8 @@ bool cpe_set_field(struct cpe_name *cpe, int idx, const char *newval) { - __attribute__nonnull__(cpe); - /*__attribute__nonnull__(newval); <-- can't be here, we want to set NULL */ + __attribute__nonnull__(cpe) + __attribute__nonnull__(newval) if (cpe == NULL) return false; @@ -162,6 +165,8 @@ struct cpe_name *cpe_name_new(const char *cpestr) { + __attribute__nonnull__(cpestr) + int i; struct cpe_name *cpe; @@ -190,7 +195,7 @@ static char **cpe_split(char *str, const char *delim) { - __attribute__nonnull__(str); + __attribute__nonnull__(str) char **stringp = &str; int alloc = CPE_SPLIT_INIT_ALLOC; @@ -219,7 +224,7 @@ static bool cpe_urldecode(char *str) { - __attribute__nonnull__(str); + __attribute__nonnull__(str) char *inptr, *outptr; @@ -246,6 +251,9 @@ bool cpe_name_match_one(const struct cpe_name * cpe, const struct cpe_name * against) { + __attribute__nonnull__(cpe) + __attribute__nonnull__(against) + int i; if (cpe == NULL || against == NULL) return false; @@ -266,8 +274,8 @@ bool cpe_name_match_cpes(const struct cpe_name * name, size_t n, struct cpe_name ** namelist) { - __attribute__nonnull__(name); - __attribute__nonnull__(namelist); + __attribute__nonnull__(name) + __attribute__nonnull__(namelist) int i; @@ -282,8 +290,8 @@ int cpe_name_match_strs(const char *candidate, size_t n, char **targets) { - __attribute__nonnull__(candidate); - __attribute__nonnull__(targets); + __attribute__nonnull__(candidate) + __attribute__nonnull__(targets) int i; struct cpe_name *ccpe, *tcpe; @@ -311,7 +319,7 @@ bool cpe_name_check(const char *str) { - __attribute__nonnull__(str); + __attribute__nonnull__(str) if (str == NULL) return false; @@ -332,13 +340,15 @@ static const char *as_str(const char *str) { + __attribute__nonnull__(str) + if (str == NULL) return ""; return str; } char *cpe_name_get_uri(const struct cpe_name * cpe) { - __attribute__nonnull__(cpe); + __attribute__nonnull__(cpe) int len = 16; int i; @@ -373,8 +383,8 @@ int cpe_name_write(const struct cpe_name * cpe, FILE * f) { - __attribute__nonnull__(cpe); - __attribute__nonnull__(f); + __attribute__nonnull__(cpe) + __attribute__nonnull__(f) int ret; char *uri; @@ -391,8 +401,7 @@ static bool cpe_assign_values(struct cpe_name * cpe, char **fields) { - __attribute__nonnull__(cpe); - __attribute__nonnull__(fields); + __attribute__nonnull__(fields) int i; @@ -408,8 +417,6 @@ void cpe_name_free(struct cpe_name * cpe) { - if (cpe == NULL) return; - int i; for (i = 0; i < CPE_FIELDNUM; ++i) cpe_set_field(cpe, i, NULL); diff -u -r a/src/CVE/cve.c b/src/CVE/cve.c --- a/src/CVE/cve.c 2009-12-11 11:40:26 -0500 +++ b/src/CVE/cve.c 2009-12-09 12:06:48 -0500 @@ -31,19 +31,22 @@ * Brian Kolbay */ +#include #include "public/cve.h" #include "cve_priv.h" #include "../common/util.h" #include "../common/list.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /** * Public function to import CVE model from OSCAP import source. * Function returns CVE model, need to free source after calling this function */ struct cve_model * cve_model_import(const struct oscap_import_source * source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) if (oscap_import_source_get_filename(source) == NULL) return NULL; @@ -61,7 +64,7 @@ */ void cve_model_export(struct cve_model * cve, const struct oscap_export_target * target) { - __attribute__nonnull__(target); + __attribute__nonnull__(target) if (oscap_export_target_get_filename(target) == NULL) return; diff -u -r a/src/CVE/cve_priv.c b/src/CVE/cve_priv.c --- a/src/CVE/cve_priv.c 2009-12-11 11:40:26 -0500 +++ b/src/CVE/cve_priv.c 2009-12-09 13:04:36 -0500 @@ -31,16 +31,19 @@ #include #include +#include #include "cve_priv.h" #include "public/cve.h" -#include "cpelang_priv.h" -#include "cvss_priv.h" -#include "cvss.h" +#include "../CPE/cpelang_priv.h" +#include "../CVSS/cvss_priv.h" +#include "../CVSS/public/cvss.h" #include "../list.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /***************************************************************************/ /* Variable definitions * */ @@ -356,7 +359,7 @@ */ static int xmlTextReaderNextElement(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) int ret; do { @@ -369,7 +372,7 @@ static bool cve_validate_xml(const char * filename) { - __attribute__nonnull__(filename); + __attribute__nonnull__(filename) xmlParserCtxtPtr ctxt; /* the parser context */ xmlDocPtr doc; /* the resulting document tree */ @@ -402,7 +405,7 @@ */ struct cve_model * cve_model_parse_xml(const struct oscap_import_source * source) { - __attribute__nonnull__(source); + __attribute__nonnull__(source) xmlTextReaderPtr reader; struct cve_model *ret = NULL; @@ -424,7 +427,7 @@ struct cve_model * cve_model_parse(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) struct cve_model *ret = NULL; struct xml_metadata *xml = NULL; @@ -467,7 +470,7 @@ struct cve_entry * cve_entry_parse(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) struct cve_entry *ret; struct cve_product *product; @@ -604,8 +607,8 @@ */ void cve_model_export_xml(struct cve_model * cve, const struct oscap_export_target * target) { - __attribute__nonnull__(cve); - __attribute__nonnull__(target); + __attribute__nonnull__(cve) + __attribute__nonnull__(target) /* TODO: ad macro to check return value from xmlTextWriter* functions */ xmlTextWriterPtr writer; @@ -625,8 +628,8 @@ void cve_export(const struct cve_model * cve, xmlTextWriterPtr writer) { - __attribute__nonnull__(cve); - __attribute__nonnull__(writer); + __attribute__nonnull__(cve) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST cve->xml.namespace, TAG_NVD_STR, BAD_CAST NULL); if ((cve->xml.lang) != NULL) @@ -645,8 +648,8 @@ void cve_reference_export(const struct cve_reference * refer, xmlTextWriterPtr writer) { - __attribute__nonnull__(refer); - __attribute__nonnull__(writer); + __attribute__nonnull__(refer) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST refer->xml.namespace, TAG_REFERENCES_STR, BAD_CAST NULL); @@ -680,8 +683,8 @@ void cve_summary_export(const struct cve_summary * sum, xmlTextWriterPtr writer) { - __attribute__nonnull__(sum); - __attribute__nonnull__(writer); + __attribute__nonnull__(sum) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST sum->xml.namespace, TAG_SUMMARY_STR, BAD_CAST NULL); if ((sum->xml.lang) != NULL) @@ -693,8 +696,8 @@ void cve_entry_export(const struct cve_entry * entry, xmlTextWriterPtr writer) { - __attribute__nonnull__(entry); - __attribute__nonnull__(writer); + __attribute__nonnull__(entry) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, BAD_CAST entry->xml.namespace, TAG_CVE_STR, BAD_CAST NULL); if ((entry->id) != NULL) diff -u -r a/src/CVE/public/cve.h b/src/CVE/public/cve.h --- a/src/CVE/public/cve.h 2009-12-11 11:40:26 -0500 +++ b/src/CVE/public/cve.h 2009-12-09 12:09:20 -0500 @@ -39,7 +39,7 @@ #include #include "oscap.h" -#include "cpeuri.h" +#include "../CPE/public/cpeuri.h" /** * @struct cve_model diff -u -r a/src/CVSS/cvss.c b/src/CVSS/cvss.c --- a/src/CVSS/cvss.c 2009-12-11 11:40:26 -0500 +++ b/src/CVSS/cvss.c 2009-12-10 10:29:46 -0500 @@ -33,10 +33,13 @@ #include #include +#include #include "cvss_priv.h" #include "public/cvss.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /** * A test class. A more elaborate class description. */ @@ -166,6 +169,11 @@ double *impact_score, double *exploitability_score) { + __attribute__nonnull__(entry) + __attribute__nonnull__(base_score) + __attribute__nonnull__(impact_score) + __attribute__nonnull__(exploitability_score) + cvss_access_vector_t ave = (cvss_access_vector_t) cvss_map_av_get(cvss_entry_get_AV(entry)); cvss_access_complexity_t ace = (cvss_access_complexity_t) cvss_map_ac_get(cvss_entry_get_AC(entry)); @@ -184,6 +192,9 @@ double *impact_score, double *exploitability_score) { + __attribute__nonnull__(base_score) + __attribute__nonnull__(impact_score) + __attribute__nonnull__(exploitability_score) double av, ac, au, ci, ii, ai, bs, is, es; @@ -214,6 +225,7 @@ cvss_report_confidence_t rce, double base_score, double *temporal_score) { + __attribute__nonnull__(temporal_score) double ex, rl, rc, ts; @@ -238,6 +250,7 @@ cvss_exploitability_t exe, cvss_remediation_level_t rle, cvss_report_confidence_t rce) { + __attribute__nonnull__(enviromental_score) double cd, td, cr, ir, ar, ais, aes, abss, ats, envs; double av, ac, au, ci, ii, ai, ex, rl, rc; diff -u -r a/src/CVSS/cvss_priv.c b/src/CVSS/cvss_priv.c --- a/src/CVSS/cvss_priv.c 2009-12-11 11:40:26 -0500 +++ b/src/CVSS/cvss_priv.c 2009-12-09 12:11:33 -0500 @@ -30,11 +30,14 @@ #include #include #include +#include #include "cvss_priv.h" #include "public/cvss.h" #include "../common/list.h" +#define __attribute__nonnull__(x) assert((x) == NULL); + /***************************************************************************/ /* Variable definitions * */ @@ -134,7 +137,7 @@ /***************************************************************************/ int cvss_map_av_get(const char * string) { - __attribute__nonnull__(string); + __attribute__nonnull__(string) const struct cvss_map_av* map = CVSS_MAP_AV; while (map->name) { @@ -146,7 +149,7 @@ } int cvss_map_ac_get(const char * string) { - __attribute__nonnull__(string); + __attribute__nonnull__(string) const struct cvss_map_ac* map = CVSS_MAP_AC; while (map->name) { @@ -158,7 +161,7 @@ } int cvss_map_auth_get(const char * string) { - __attribute__nonnull__(string); + __attribute__nonnull__(string) const struct cvss_map_auth* map = CVSS_MAP_AUTH; while (map->name) { @@ -170,7 +173,7 @@ } int cvss_map_imp_get(const char * string) { - __attribute__nonnull__(string); + __attribute__nonnull__(string) const struct cvss_map_imp* map = CVSS_MAP_IMP; while (map->name) { @@ -226,7 +229,7 @@ */ static int xmlTextReaderNextElement(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) int ret; do { @@ -245,7 +248,7 @@ */ struct cvss_entry * cvss_entry_parse(xmlTextReaderPtr reader) { - __attribute__nonnull__(reader); + __attribute__nonnull__(reader) struct cvss_entry *ret = NULL; @@ -323,8 +326,8 @@ */ void cvss_entry_export(const struct cvss_entry * entry, xmlTextWriterPtr writer) { - __attribute__nonnull__(entry); - __attribute__nonnull__(writer); + __attribute__nonnull__(entry) + __attribute__nonnull__(writer) xmlTextWriterStartElementNS(writer, NS_VULN_STR, TAG_CVSS_STR, BAD_CAST NULL); xmlTextWriterStartElementNS(writer, NS_CVSS_STR, TAG_BASE_METRICS_STR, BAD_CAST NULL); diff -u -r a/src/OVAL/oval_affected.c b/src/OVAL/oval_affected.c --- a/src/OVAL/oval_affected.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_affected.c 2009-12-10 12:57:27 -0500 @@ -37,6 +37,7 @@ #include "../common/util.h" typedef struct oval_affected { + struct oval_definition_model *model; oval_affected_family_t family; struct oval_collection *platforms; struct oval_collection *products; @@ -80,10 +81,11 @@ oval_collection_iterator(affected->products); } -struct oval_affected *oval_affected_new() +struct oval_affected *oval_affected_new(struct oval_definition_model* model) { struct oval_affected *affected = (struct oval_affected *)malloc(sizeof(oval_affected_t)); + affected->model = model; affected->family = OVAL_AFCFML_UNKNOWN; affected->platforms = oval_collection_new(); affected->products = oval_collection_new(); @@ -96,12 +98,12 @@ } bool oval_affected_is_locked(struct oval_affected *affected) { - return false;//TODO + return oval_definition_model_is_locked(affected->model); } -struct oval_affected *oval_affected_clone(struct oval_affected *old_affected) +struct oval_affected *oval_affected_clone(struct oval_definition_model *new_model, struct oval_affected *old_affected) { - struct oval_affected *new_affected = oval_affected_new(); + struct oval_affected *new_affected = oval_affected_new(new_model); oval_affected_set_family(new_affected, old_affected->family); @@ -133,31 +135,25 @@ void oval_affected_set_family(struct oval_affected *affected, oval_affected_family_t family) { - affected->family = family; + + if(!oval_affected_is_locked(affected)){ + affected->family = family; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_affected_add_platform(struct oval_affected *affected, char *platform) { - oval_collection_add(affected->platforms, (void *)strdup(platform)); + if(affected && !oval_affected_is_locked(affected)){ + oval_collection_add(affected->platforms, (void *)strdup(platform)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_affected_add_product(struct oval_affected *affected, char *product) { - oval_collection_add(affected->products, (void *)strdup(product)); -} - -/* -struct oval_string_map *_odafamilyMap = NULL; -typedef struct _odafamily { - int value; -} _odafamily_t; -void _odafamily_set(char *name, int val) -{ - _odafamily_t *enumval = (_odafamily_t *) malloc(sizeof(_odafamily_t)); - enumval->value = val; - oval_string_map_put(_odafamilyMap, name, (void *)enumval); + if(affected && !oval_affected_is_locked(affected)){ + oval_collection_add(affected->products, (void *)strdup(product)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } -*/ static const struct oscap_string_map OVAL_ODAFAMILY_MAP[] = { { OVAL_AFCFML_CATOS, "catos" }, @@ -218,7 +214,7 @@ struct oval_parser_context *context, oval_affected_consumer consumer, void *user) { - struct oval_affected *affected = oval_affected_new(); + struct oval_affected *affected = oval_affected_new(context->definition_model); //xmlChar *tagname = xmlTextReaderName(reader); //xmlChar *namespace = xmlTextReaderNamespaceUri(reader); char *family = (char*) xmlTextReaderGetAttribute(reader, BAD_CAST "family"); diff -u -r a/src/OVAL/oval_agent.c b/src/OVAL/oval_agent.c --- a/src/OVAL/oval_agent.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_agent.c 2009-12-11 16:16:59 -0500 @@ -32,6 +32,7 @@ #include "oval_parser_impl.h" #include "oval_string_map_impl.h" #include "oval_system_characteristics_impl.h" +#include "oval_probe_impl.h" #include "oval_results_impl.h" #include #include @@ -78,7 +79,7 @@ struct oval_string_map *object_map; struct oval_string_map *state_map; struct oval_string_map *variable_map; - struct oval_sysinfo *sysinfoX; + bool is_locked; } oval_definition_model_t; struct oval_definition_model *oval_definition_model_new() @@ -90,15 +91,16 @@ newmodel->state_map = oval_string_map_new(); newmodel->test_map = oval_string_map_new(); newmodel->variable_map = oval_string_map_new(); + newmodel->is_locked = false; return newmodel; } void oval_definition_model_lock(struct oval_definition_model *definition_model) { - //TODO + if(definition_model && oval_definition_model_is_valid(definition_model))definition_model->is_locked = true; } bool oval_definition_model_is_locked(struct oval_definition_model *definition_model) { - return false;//TODO + return definition_model->is_locked; } bool oval_definition_model_is_valid(struct oval_definition_model *definition_model) { @@ -114,7 +116,7 @@ while(oval_string_iterator_has_more(keys)){ char *key = oval_string_iterator_next(keys); void *olditem = oval_string_map_get_value(oldmap, key); - (*cloner)(olditem, newmodel); + (*cloner)(newmodel, olditem); } oval_string_iterator_free(keys); } @@ -165,6 +167,7 @@ struct oval_string_map *syschar_map; struct oval_string_map *sysdata_map; struct oval_string_map *variable_binding_map; + bool is_locked; } oval_syschar_model_t; struct oval_syschar_model *oval_syschar_model_new( @@ -177,16 +180,17 @@ newmodel->syschar_map = oval_string_map_new(); newmodel->sysdata_map = oval_string_map_new(); newmodel->variable_binding_map = oval_string_map_new(); + newmodel->is_locked = false; return newmodel; } void oval_syschar_model_lock(struct oval_syschar_model *syschar_model) { - //TODO + if(syschar_model && oval_syschar_model_is_valid(syschar_model))syschar_model->is_locked = true; } bool oval_syschar_model_is_locked(struct oval_syschar_model *syschar_model) { - return false;//TODO + return syschar_model->is_locked; } bool oval_syschar_model_is_valid(struct oval_syschar_model *syschar_model) { @@ -209,7 +213,7 @@ while(oval_string_iterator_has_more(keys)){ char *key = oval_string_iterator_next(keys); void *olditem = oval_string_map_get_value(oldmap, key); - (*cloner)(olditem, newmodel); + (*cloner)(newmodel, olditem); } oval_string_iterator_free(keys); } @@ -224,7 +228,7 @@ _oval_syschar_model_clone(old_model->variable_binding_map, new_model, (_oval_syschar_model_clone_func)_oval_syschar_model_clone_variable_binding); struct oval_sysinfo *old_sysinfo = oval_syschar_model_get_sysinfo(old_model); - struct oval_sysinfo *new_sysinfo = oval_sysinfo_clone(old_sysinfo); + struct oval_sysinfo *new_sysinfo = oval_sysinfo_clone(new_model, old_sysinfo); oval_syschar_model_set_sysinfo(new_model, new_sysinfo); return new_model; } @@ -279,60 +283,74 @@ void oval_syschar_model_set_sysinfo(struct oval_syschar_model *model, struct oval_sysinfo *sysinfo) { - if(sysinfo){ - model->sysinfo = oval_sysinfo_clone(sysinfo); - } + if(model && !oval_syschar_model_is_locked(model)){ + model->sysinfo = oval_sysinfo_clone(model, sysinfo); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_model_add_definition( struct oval_definition_model *model, struct oval_definition *definition) { - char *key = oval_definition_get_id(definition); - oval_string_map_put(model->definition_map, key, (void *)definition); + if(model && !oval_definition_model_is_locked(model)){ + char *key = oval_definition_get_id(definition); + oval_string_map_put(model->definition_map, key, (void *)definition); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_model_add_test(struct oval_definition_model *model, struct oval_test *test) { - char *key = oval_test_get_id(test); - oval_string_map_put(model->test_map, key, (void *)test); + if(model && !oval_definition_model_is_locked(model)){ + char *key = oval_test_get_id(test); + oval_string_map_put(model->test_map, key, (void *)test); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_model_add_object(struct oval_definition_model *model, struct oval_object *object) { - char *key = oval_object_get_id(object); - oval_string_map_put(model->object_map, key, (void *)object); + if(model && !oval_definition_model_is_locked(model)){ + char *key = oval_object_get_id(object); + oval_string_map_put(model->object_map, key, (void *)object); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_model_add_state(struct oval_definition_model *model, struct oval_state *state) { - char *key = oval_state_get_id(state); - oval_string_map_put(model->state_map, key, (void *)state); + if(model && !oval_definition_model_is_locked(model)){ + char *key = oval_state_get_id(state); + oval_string_map_put(model->state_map, key, (void *)state); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_model_add_variable(struct oval_definition_model *model, struct oval_variable *variable) { - char *key = oval_variable_get_id(variable); - oval_string_map_put(model->variable_map, key, (void *)variable); + if(model && !oval_definition_model_is_locked(model)){ + char *key = oval_variable_get_id(variable); + oval_string_map_put(model->variable_map, key, (void *)variable); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_syschar_model_add_syschar(struct oval_syschar_model *model, struct oval_syschar *syschar) { - struct oval_object *object = oval_syschar_get_object(syschar); - if(object!=NULL){ - char *id = oval_object_get_id(object); - oval_string_map_put(model->syschar_map, id, syschar); - } + if(model && !oval_syschar_model_is_locked(model)){ + struct oval_object *object = oval_syschar_get_object(syschar); + if(object!=NULL){ + char *id = oval_object_get_id(object); + oval_string_map_put(model->syschar_map, id, syschar); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_syschar_model_add_variable_binding(struct oval_syschar_model *model, struct oval_variable_binding *binding) { - struct oval_variable *variable = oval_variable_binding_get_variable(binding); - char *varid = oval_variable_get_id(variable); - oval_string_map_put(model->variable_binding_map, varid, binding); + if(model && !oval_syschar_model_is_locked(model)){ + struct oval_variable *variable = oval_variable_binding_get_variable(binding); + char *varid = oval_variable_get_id(variable); + oval_string_map_put(model->variable_binding_map, varid, binding); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_syschar_model_probe_objects(struct oval_syschar_model *syschar_model) @@ -354,10 +372,10 @@ syschar = oval_probe_object_eval (pctx, object); if(syschar == NULL) { - syschar = oval_syschar_new(object); + syschar = oval_syschar_new(syschar_model, object); oval_syschar_set_flag(syschar,SYSCHAR_FLAG_NOT_COLLECTED); } - oval_syschar_model_add_syschar(syschar_model, syschar); + oval_syschar_model_add_syschar(syschar_model, syschar); } } @@ -368,10 +386,12 @@ void oval_syschar_model_add_sysdata(struct oval_syschar_model *model, struct oval_sysdata *sysdata) { - char *id = oval_sysdata_get_id(sysdata); - if(id!=NULL){ - oval_string_map_put(model->sysdata_map, id, sysdata); - } + if(model && !oval_syschar_model_is_locked(model)){ + char *id = oval_sysdata_get_id(sysdata); + if(id!=NULL){ + oval_string_map_put(model->sysdata_map, id, sysdata); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } int oval_definition_model_import(struct oval_definition_model *model, @@ -447,10 +467,10 @@ } void oval_definition_model_bind_variable_model - (struct oval_definition_model *sysmodel, struct oval_variable_model *varmodel) + (struct oval_definition_model *defmodel, struct oval_variable_model *varmodel) { //Bind values to all external variables specified in the variable model. - struct oval_variable_iterator *variables = oval_definition_model_get_variables(sysmodel); + struct oval_variable_iterator *variables = oval_definition_model_get_variables(defmodel); while(oval_variable_iterator_has_more(variables)){ struct oval_variable *variable = oval_variable_iterator_next(variables); if(oval_variable_get_type(variable)==OVAL_VARIABLE_EXTERNAL){ @@ -545,7 +565,7 @@ char *object_id = oval_object_get_id(object); struct oval_syschar *syschar = oval_syschar_model_get_syschar(model, object_id); if (syschar == NULL) { - syschar = oval_syschar_new(object); + syschar = oval_syschar_new(model, object); oval_syschar_model_add_syschar(model, syschar); } return syschar; @@ -555,7 +575,7 @@ { struct oval_sysdata *sysdata = oval_syschar_model_get_sysdata(model, id); if (sysdata == NULL) { - sysdata = oval_sysdata_new(id); + sysdata = oval_sysdata_new(model, id); oval_syschar_model_add_sysdata(model, sysdata); } return sysdata; @@ -565,7 +585,7 @@ { struct oval_definition *definition = oval_definition_model_get_definition(model, id); if (definition == NULL) { - definition = oval_definition_new(id); + definition = oval_definition_new(model, id); oval_definition_model_add_definition(model, definition); } return definition; @@ -576,7 +596,7 @@ { struct oval_variable *variable = oval_definition_model_get_variable(model, id); if (variable == NULL) { - variable = oval_variable_new(id, type); + variable = oval_variable_new(model, id, type); oval_definition_model_add_variable(model, variable); }else{ oval_variable_set_type(variable, type); @@ -588,7 +608,7 @@ { struct oval_state *state = oval_definition_model_get_state(model, id); if (state == NULL) { - state = oval_state_new(id); + state = oval_state_new(model, id); oval_definition_model_add_state(model, state); } return state; @@ -598,7 +618,7 @@ { struct oval_object *object = oval_definition_model_get_object(model, id); if (object == NULL) { - object = oval_object_new(id); + object = oval_object_new(model, id); oval_definition_model_add_object(model, object); } return object; @@ -608,7 +628,7 @@ { struct oval_test *test = oval_definition_model_get_test(model, id); if (test == NULL) { - test = oval_test_new(id); + test = oval_test_new(model, id); oval_definition_model_add_test(model, test); } return test; @@ -636,6 +656,7 @@ struct oval_results_model{ struct oval_definition_model *definition_model; struct oval_collection *systems; + bool is_locked; }; typedef struct oval_results_model oval_results_model_t; @@ -652,20 +673,21 @@ struct oval_syschar_model *syschar_model; for(syschar_model = *syschar_models;syschar_model; syschar_model = *(++syschar_models)){ - struct oval_result_system *sys = oval_result_system_new(syschar_model); + struct oval_result_system *sys = oval_result_system_new(model, syschar_model); oval_results_model_add_system(model, sys); } } + model->is_locked = false; return model; } void oval_results_model_lock(struct oval_results_model *results_model) { - //TODO + if(results_model && oval_results_model_is_valid(results_model))results_model->is_locked = true; } bool oval_results_model_is_locked(struct oval_results_model *results_model) { - return false;//TODO + return results_model->is_locked; } bool oval_results_model_is_valid(struct oval_results_model *results_model) { @@ -680,7 +702,8 @@ struct oval_result_system_iterator *old_systems = oval_results_model_get_systems(old_resmodel); while(oval_result_system_iterator_has_more(old_systems)){ struct oval_result_system *old_system = oval_result_system_iterator_next(old_systems); - oval_result_system_clone(old_system, new_resmodel); + struct oval_result_system *new_system = oval_result_system_clone(new_resmodel, old_system); + oval_results_model_add_system(new_resmodel, new_system); } oval_result_system_iterator_free(old_systems); @@ -713,7 +736,9 @@ void oval_results_model_add_system (struct oval_results_model *model, struct oval_result_system *sys) { - if(sys)oval_collection_add(model->systems, sys); + if(model && !oval_results_model_is_locked(model)){ + if(sys)oval_collection_add(model->systems, sys); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_result_directives *oval_results_model_import @@ -937,8 +962,10 @@ int i;for(i=0;oval_definition_iterator_has_more(definitions); i++){ struct oval_definition *definition = oval_definition_iterator_next(definitions); if(resolver==NULL || (*resolver)(definition, user_arg)){ - if(definitions_node==NULL)definitions_node + if(definitions_node==NULL){ + definitions_node = xmlNewChild(root_node, ns_defntns, BAD_CAST "definitions", NULL); + } oval_definition_to_dom (definition, doc, definitions_node); struct oval_criteria_node *criteria = oval_definition_get_criteria(definition); @@ -1156,7 +1183,8 @@ (struct oval_definition *oval_definition, struct oval_string_map *defids) { char *defid = oval_definition_get_id(oval_definition); - return oval_string_map_get_value(defids, defid)!=NULL; + bool resolved = oval_string_map_get_value(defids, defid)!=NULL; + return resolved; } static xmlNode *oval_results_to_dom @@ -1232,11 +1260,12 @@ static int item_id = 1; struct oval_syschar *oval_probe_object_eval (oval_pctx_t *pctx, struct oval_object *object) { - struct oval_syschar *syschar = oval_syschar_new(object); + struct oval_syschar_model *model = pctx->model; + struct oval_syschar *syschar = oval_syschar_new(model, object); oval_syschar_set_flag(syschar, SYSCHAR_STATUS_NOT_COLLECTED); char itemid[10]; snprintf(itemid, sizeof(item_id), "%d", (++item_id)); - struct oval_sysdata *sysdata = oval_sysdata_new(itemid); + struct oval_sysdata *sysdata = oval_sysdata_new(model, itemid); oval_sysdata_set_status(sysdata, SYSCHAR_STATUS_NOT_COLLECTED); oval_sysdata_set_subtype(sysdata, oval_object_get_subtype(object)); oval_syschar_add_sysdata(syschar, sysdata); @@ -1248,5 +1277,5 @@ return (NULL); } void oval_pctx_free (oval_pctx_t *ctx){} -oval_pctx_t *oval_pctx_new (struct oval_syschar_model *model){return (NULL);} +oval_pctx_t *oval_pctx_new (struct oval_syschar_model *sys){return (NULL);} #endif diff -u -r a/src/OVAL/oval_agent_api_impl.h b/src/OVAL/oval_agent_api_impl.h --- a/src/OVAL/oval_agent_api_impl.h 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_agent_api_impl.h 2009-12-10 13:11:13 -0500 @@ -57,14 +57,20 @@ struct oval_state *oval_state_get_new(struct oval_definition_model *, char *); struct oval_variable *oval_variable_get_new(struct oval_definition_model *, char *, oval_variable_type_t type); -struct oval_definition *oval_definition_clone(struct oval_definition *, struct oval_definition_model *); -struct oval_test *oval_test_clone (struct oval_test *, struct oval_definition_model *); -struct oval_object *oval_object_clone (struct oval_object *, struct oval_definition_model *); -struct oval_state *oval_state_clone (struct oval_state *, struct oval_definition_model *); -struct oval_variable *oval_variable_clone (struct oval_variable *, struct oval_definition_model *); +struct oval_definition *oval_definition_clone +(struct oval_definition_model *new_model, struct oval_definition *old_definition); +struct oval_test *oval_test_clone +(struct oval_definition_model *new_model, struct oval_test *old_test); +struct oval_object *oval_object_clone +(struct oval_definition_model *new_model, struct oval_object *old_object); +struct oval_state *oval_state_clone +(struct oval_definition_model *new_model, struct oval_state *old_state); +struct oval_variable *oval_variable_clone +(struct oval_definition_model* new_model, struct oval_variable *old_variable); struct oval_syschar *oval_syschar_get_new(struct oval_syschar_model *, struct oval_object *); struct oval_syschar_item *oval_syschar_item_get_new(struct oval_syschar_model *, char *); +struct oval_sysdata *oval_syschar_model_get_sysdata(struct oval_syschar_model *, char*); struct oval_sysdata *oval_sysdata_get_new(struct oval_syschar_model *model, char *id); typedef bool oval_syschar_resolver(struct oval_syschar *, void *); diff -u -r a/src/OVAL/oval_behavior.c b/src/OVAL/oval_behavior.c --- a/src/OVAL/oval_behavior.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_behavior.c 2009-12-10 13:13:15 -0500 @@ -35,6 +35,7 @@ #include "oval_string_map_impl.h" typedef struct oval_behavior { + struct oval_definition_model *model; char *value; char *key; } oval_behavior_t; @@ -69,18 +70,19 @@ return behavior->key; } -struct oval_behavior *oval_behavior_new() +struct oval_behavior *oval_behavior_new(struct oval_definition_model* model) { oval_behavior_t *behavior = (oval_behavior_t *) malloc(sizeof(oval_behavior_t)); + behavior->model = model; behavior->value = NULL; behavior->key = NULL; return behavior; } -struct oval_behavior *oval_behavior_clone(struct oval_behavior *old_behavior) +struct oval_behavior *oval_behavior_clone(struct oval_definition_model *new_model, struct oval_behavior *old_behavior) { - struct oval_behavior *new_behavior = oval_behavior_new(); + struct oval_behavior *new_behavior = oval_behavior_new(new_model); oval_behavior_set_keyval (new_behavior, oval_behavior_get_key(old_behavior), oval_behavior_get_value(old_behavior)); return new_behavior; @@ -92,7 +94,7 @@ } bool oval_behavior_is_locked(struct oval_behavior *behavior) { - return false;//TODO + return oval_definition_model_is_locked(behavior->model); } void oval_behavior_free(struct oval_behavior *behavior) @@ -106,8 +108,10 @@ void oval_behavior_set_keyval(struct oval_behavior *behavior, const char* key, const char* value) { - behavior->key = strdup(key); - behavior->value = strdup(value); + if(behavior && !oval_behavior_is_locked(behavior)){ + behavior->key = strdup(key); + behavior->value = strdup(value); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //typedef void (*oval_behavior_consumer)(struct oval_behavior_node *, void*); @@ -120,7 +124,7 @@ const char *name = (const char *) xmlTextReaderConstName(reader); const char *value = (const char *) xmlTextReaderConstValue(reader); if (name && value) { - oval_behavior_t *behavior = oval_behavior_new(); + oval_behavior_t *behavior = oval_behavior_new(context->definition_model); oval_behavior_set_keyval(behavior, name, value); (*consumer) (behavior, user); } diff -u -r a/src/OVAL/oval_component.c b/src/OVAL/oval_component.c --- a/src/OVAL/oval_component.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_component.c 2009-12-11 14:59:03 -0500 @@ -51,49 +51,58 @@ #define _FLAG_TYPE(flag) oval_syschar_collection_flag_get_text(flag) typedef struct oval_component { + struct oval_definition_model *model; oval_component_type_t type; } oval_component_t; typedef struct oval_component_LITERAL { + struct oval_definition_model *model; oval_component_type_t type; struct oval_value *value; //type==OVAL_COMPONENT_LITERAL } oval_component_LITERAL_t; typedef struct oval_component_OBJECTREF { + struct oval_definition_model *model; oval_component_type_t type; struct oval_object *object; //type==OVAL_COMPONENT_OBJECTREF char *object_field; //type==OVAL_COMPONENT_OBJECTREF } oval_component_OBJECTREF_t; typedef struct oval_component_VARREF { + struct oval_definition_model *model; oval_component_type_t type; struct oval_variable *variable; //type==OVAL_COMPONENT_VARREF } oval_component_VARREF_t; typedef struct oval_component_FUNCTION { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION } oval_component_FUNCTION_t; typedef struct oval_component_ARITHMETIC { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION oval_arithmetic_operation_t operation; //type==OVAL_COMPONENT_ARITHMETIC } oval_component_ARITHMETIC_t; typedef struct oval_component_BEGEND { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION char *character; //type==OVAL_COMPONENT_BEGIN/END } oval_component_BEGEND_t; typedef struct oval_component_SPLIT { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION char *delimiter; //type==OVAL_COMPONENT_SPLIT } oval_component_SPLIT_t; typedef struct oval_component_SUBSTRING { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION int start; //type==OVAL_COMPONENT_SUBSTRING @@ -101,6 +110,7 @@ } oval_component_SUBSTRING_t; typedef struct oval_component_TIMEDIF { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION oval_datetime_format_t format_1; //type==OVAL_COMPONENT_TIMEDIF @@ -108,6 +118,7 @@ } oval_component_TIMEDIF_t; typedef struct oval_component_REGEX_CAPTURE { + struct oval_definition_model *model; oval_component_type_t type; struct oval_collection *function_components; //type==OVAL_COMPONENT_FUNCTION char *pattern; //type==OVAL_COMPONENT_REGEX_CAPTURE @@ -157,13 +168,17 @@ (struct oval_component *component, struct oval_value *value) { //type==OVAL_COMPONENT_LITERAL - if (oval_component_get_type(component) == OVAL_COMPONENT_LITERAL) { - ((struct oval_component_LITERAL *)component)->value = value; - } + if(component && !oval_component_is_locked(component)){ + if (oval_component_get_type(component) == OVAL_COMPONENT_LITERAL) { + ((struct oval_component_LITERAL *)component)->value = value; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_component_set_type(struct oval_component *component, oval_component_type_t type) { - component->type = type; + if(component && !oval_component_is_locked(component)){ + component->type = type; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_object *oval_component_get_object @@ -180,9 +195,11 @@ (struct oval_component *component, struct oval_object *object) { //type==OVAL_COMPONENT_OBJECTREF - if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { - ((struct oval_component_OBJECTREF *)component)->object = object; - } + if(component && !oval_component_is_locked(component)){ + if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { + ((struct oval_component_OBJECTREF *)component)->object = object; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_component_get_object_field @@ -200,11 +217,13 @@ void oval_component_set_object_field (struct oval_component *component, char *field) { - //type==OVAL_COMPONENT_OBJECTREF - if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { - ((struct oval_component_OBJECTREF *)component)-> - object_field = strdup(field); - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_OBJECTREF + if (oval_component_get_type(component) == OVAL_COMPONENT_OBJECTREF) { + ((struct oval_component_OBJECTREF *)component)-> + object_field = strdup(field); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_variable *oval_component_get_variable @@ -253,12 +272,14 @@ void oval_component_set_arithmetic_operation (struct oval_component *component, oval_arithmetic_operation_t operation) { - //type==OVAL_COMPONENT_ARITHMETIC - if (component->type == OVAL_FUNCTION_ARITHMETIC) { - oval_component_ARITHMETIC_t *arithmetic = - (oval_component_ARITHMETIC_t *) component; - arithmetic->operation = operation; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_ARITHMETIC + if (component->type == OVAL_FUNCTION_ARITHMETIC) { + oval_component_ARITHMETIC_t *arithmetic = + (oval_component_ARITHMETIC_t *) component; + arithmetic->operation = operation; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_component_get_prefix(struct oval_component *component) @@ -276,12 +297,14 @@ void oval_component_set_prefix (struct oval_component *component, char *character) { - //type==OVAL_COMPONENT_BEGIN - if (component->type == OVAL_FUNCTION_BEGIN) { - oval_component_BEGEND_t *begin = - (oval_component_BEGEND_t *) component; - begin->character = strdup(character); - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_BEGIN + if (component->type == OVAL_FUNCTION_BEGIN) { + oval_component_BEGEND_t *begin = + (oval_component_BEGEND_t *) component; + begin->character = strdup(character); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_component_get_suffix(struct oval_component *component) @@ -344,12 +367,14 @@ } void oval_component_set_substring_start(struct oval_component *component, int start) { - //type==OVAL_COMPONENT_SUBSTRING - if (component->type == OVAL_FUNCTION_SUBSTRING) { - oval_component_SUBSTRING_t *substring = - (oval_component_SUBSTRING_t *) component; - substring->start = start; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_SUBSTRING + if (component->type == OVAL_FUNCTION_SUBSTRING) { + oval_component_SUBSTRING_t *substring = + (oval_component_SUBSTRING_t *) component; + substring->start = start; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } int oval_component_get_substring_length(struct oval_component *component) @@ -367,12 +392,14 @@ void oval_component_set_substring_length (struct oval_component *component, int length) { - //type==OVAL_COMPONENT_SUBSTRING - if (component->type == OVAL_FUNCTION_SUBSTRING) { - oval_component_SUBSTRING_t *substring = - (oval_component_SUBSTRING_t *) component; - substring->length = length; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_SUBSTRING + if (component->type == OVAL_FUNCTION_SUBSTRING) { + oval_component_SUBSTRING_t *substring = + (oval_component_SUBSTRING_t *) component; + substring->length = length; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } oval_datetime_format_t oval_component_get_timedif_format_1(struct oval_component @@ -391,12 +418,14 @@ void oval_component_set_timedif_format_1 (struct oval_component *component, oval_datetime_format_t format) { - //type==OVAL_COMPONENT_TIMEDIF - if (component->type == OVAL_FUNCTION_TIMEDIF) { - oval_component_TIMEDIF_t *timedif = - (oval_component_TIMEDIF_t *) component; - timedif->format_1 = format; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_TIMEDIF + if (component->type == OVAL_FUNCTION_TIMEDIF) { + oval_component_TIMEDIF_t *timedif = + (oval_component_TIMEDIF_t *) component; + timedif->format_1 = format; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } oval_datetime_format_t oval_component_get_timedif_format_2(struct oval_component @@ -415,12 +444,14 @@ void oval_component_set_timedif_format_2 (struct oval_component *component, oval_datetime_format_t format) { - //type==OVAL_COMPONENT_TIMEDIF - if (component->type == OVAL_FUNCTION_TIMEDIF) { - oval_component_TIMEDIF_t *timedif = - (oval_component_TIMEDIF_t *) component; - timedif->format_2 = format; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_TIMEDIF + if (component->type == OVAL_FUNCTION_TIMEDIF) { + oval_component_TIMEDIF_t *timedif = + (oval_component_TIMEDIF_t *) component; + timedif->format_2 = format; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_component_get_regex_pattern @@ -438,15 +469,17 @@ void oval_component_set_regex_pattern (struct oval_component *component, char *pattern) { - //type==OVAL_COMPONENT_REGEX_CAPTURE - if (component->type == OVAL_FUNCTION_REGEX_CAPTURE) { - oval_component_REGEX_CAPTURE_t *regex = - (oval_component_REGEX_CAPTURE_t *) component; - regex->pattern = (pattern)?NULL:strdup(pattern); - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_REGEX_CAPTURE + if (component->type == OVAL_FUNCTION_REGEX_CAPTURE) { + oval_component_REGEX_CAPTURE_t *regex = + (oval_component_REGEX_CAPTURE_t *) component; + regex->pattern = (pattern)?NULL:strdup(pattern); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } -struct oval_component *oval_component_new(oval_component_type_t type) +struct oval_component *oval_component_new(struct oval_definition_model* model, oval_component_type_t type) { oval_component_t *component; switch (type) { @@ -562,6 +595,7 @@ } component->type = type; + component->model = model; return component; } @@ -571,7 +605,7 @@ } bool oval_component_is_locked(struct oval_component *component) { - return false;//TODO + return oval_definition_model_is_locked(component->model); } void _oval_component_clone_subcomponents @@ -580,14 +614,14 @@ struct oval_component_iterator *subcomps = oval_component_get_function_components(old_component); if(subcomps)while(oval_component_iterator_has_more(subcomps)){ struct oval_component *subcomp = oval_component_iterator_next(subcomps); - oval_component_add_function_component(new_component, oval_component_clone(subcomp, model)); + oval_component_add_function_component(new_component, oval_component_clone(model, subcomp)); } oval_component_iterator_free(subcomps); } -struct oval_component *oval_component_clone(struct oval_component *old_component, struct oval_definition_model *model) +struct oval_component *oval_component_clone(struct oval_definition_model *new_model, struct oval_component *old_component) { - struct oval_component *new_component = oval_component_new(old_component->type); + struct oval_component *new_component = oval_component_new(new_model, old_component->type); switch(new_component->type){ case OVAL_FUNCTION_ARITHMETIC:{ oval_arithmetic_operation_t operation = oval_component_get_arithmetic_operation(old_component); @@ -608,7 +642,7 @@ case OVAL_COMPONENT_OBJECTREF:{ struct oval_object *old_object = oval_component_get_object(old_component); if(old_object){ - struct oval_object *new_object = oval_object_clone(old_object, model); + struct oval_object *new_object = oval_object_clone(new_model, old_object); oval_component_set_object(new_component, new_object); } char *field = oval_component_get_object_field(old_component); @@ -637,13 +671,13 @@ case OVAL_COMPONENT_VARREF:{ struct oval_variable *old_variable = oval_component_get_variable(old_component); if(old_variable){ - struct oval_variable *new_variable = oval_variable_clone(old_variable, model); + struct oval_variable *new_variable = oval_variable_clone(new_model, old_variable); oval_component_set_variable(new_component, new_variable); } }break; default: /*NOOP*/break; } - if(new_component->type>OVAL_FUNCTION)_oval_component_clone_subcomponents(old_component, new_component, model); + if(new_component->type>OVAL_FUNCTION)_oval_component_clone_subcomponents(old_component, new_component, new_model); return new_component; } @@ -709,21 +743,25 @@ void oval_component_add_function_component (struct oval_component *component, struct oval_component *func_component) { - if(component->type>OVAL_FUNCTION){ - oval_component_FUNCTION_t *function = (oval_component_FUNCTION_t *)component; - if(func_component)oval_collection_add(function->function_components, func_component); - } + if(component && !oval_component_is_locked(component)){ + if(component->type>OVAL_FUNCTION){ + oval_component_FUNCTION_t *function = (oval_component_FUNCTION_t *)component; + if(func_component)oval_collection_add(function->function_components, func_component); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_component_set_variable(struct oval_component *component, struct oval_variable *variable) { - //type==OVAL_COMPONENT_VARREF - if (component->type == OVAL_COMPONENT_VARREF) { - oval_component_VARREF_t *varref = - (oval_component_VARREF_t *) component; - varref->variable = variable; - } + if(component && !oval_component_is_locked(component)){ + //type==OVAL_COMPONENT_VARREF + if (component->type == OVAL_COMPONENT_VARREF) { + oval_component_VARREF_t *varref = + (oval_component_VARREF_t *) component; + varref->variable = variable; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void oval_value_consume(struct oval_value *value, void *component) { @@ -878,66 +916,67 @@ struct oval_parser_context *context, oval_component_consumer consumer, void *user) { + struct oval_definition_model *model = context->definition_model; char *tagname = (char *) xmlTextReaderName(reader); //oval_component_type_enum type; int return_code = 0; struct oval_component *component = NULL; if (strcmp(tagname, "literal_component") == 0) { - component = oval_component_new(OVAL_COMPONENT_LITERAL); + component = oval_component_new(model, OVAL_COMPONENT_LITERAL); return_code = _oval_component_parse_LITERAL_tag(reader, context, component); } else if (strcmp(tagname, "object_component") == 0) { - component = oval_component_new(OVAL_COMPONENT_OBJECTREF); + component = oval_component_new(model, OVAL_COMPONENT_OBJECTREF); return_code = _oval_component_parse_OBJECTREF_tag(reader, context, component); } else if (strcmp(tagname, "variable_component") == 0) { - component = oval_component_new(OVAL_COMPONENT_VARREF); + component = oval_component_new(model, OVAL_COMPONENT_VARREF); return_code = _oval_component_parse_VARREF_tag(reader, context, component); } else if (strcmp(tagname, "arithmetic") == 0) { - component = oval_component_new(OVAL_FUNCTION_ARITHMETIC); + component = oval_component_new(model, OVAL_FUNCTION_ARITHMETIC); return_code = _oval_component_parse_ARITHMETIC_tag(reader, context, component); } else if (strcmp(tagname, "begin") == 0) { - component = oval_component_new(OVAL_FUNCTION_BEGIN); + component = oval_component_new(model, OVAL_FUNCTION_BEGIN); return_code = _oval_component_parse_BEGEND_tag(reader, context, component); } else if (strcmp(tagname, "concat") == 0) { - component = oval_component_new(OVAL_FUNCTION_CONCAT); + component = oval_component_new(model, OVAL_FUNCTION_CONCAT); return_code = _oval_component_parse_FUNCTION_tag(reader, context, component); } else if (strcmp(tagname, "end") == 0) { - component = oval_component_new(OVAL_FUNCTION_END); + component = oval_component_new(model, OVAL_FUNCTION_END); return_code = _oval_component_parse_BEGEND_tag(reader, context, component); } else if (strcmp(tagname, "escape_regex") == 0) { - component = oval_component_new(OVAL_FUNCTION_ESCAPE_REGEX); + component = oval_component_new(model, OVAL_FUNCTION_ESCAPE_REGEX); return_code = _oval_component_parse_FUNCTION_tag(reader, context, component); } else if (strcmp(tagname, "split") == 0) { - component = oval_component_new(OVAL_FUNCTION_SPLIT); + component = oval_component_new(model, OVAL_FUNCTION_SPLIT); return_code = _oval_component_parse_SPLIT_tag(reader, context, component); } else if (strcmp(tagname, "substring") == 0) { - component = oval_component_new(OVAL_FUNCTION_SUBSTRING); + component = oval_component_new(model, OVAL_FUNCTION_SUBSTRING); return_code = _oval_component_parse_SUBSTRING_tag(reader, context, component); } else if (strcmp(tagname, "time_difference") == 0) { - component = oval_component_new(OVAL_FUNCTION_TIMEDIF); + component = oval_component_new(model, OVAL_FUNCTION_TIMEDIF); return_code = _oval_component_parse_TIMEDIF_tag(reader, context, component); } else if (strcmp(tagname, "regex_capture") == 0) { - component = oval_component_new(OVAL_FUNCTION_REGEX_CAPTURE); + component = oval_component_new(model, OVAL_FUNCTION_REGEX_CAPTURE); return_code = _oval_component_parse_REGEX_CAPTURE_tag(reader, context, component); diff -u -r a/src/OVAL/oval_criteriaNode.c b/src/OVAL/oval_criteriaNode.c --- a/src/OVAL/oval_criteriaNode.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_criteriaNode.c 2009-12-11 13:41:18 -0500 @@ -35,12 +35,14 @@ #include "oval_agent_api_impl.h" typedef struct oval_criteria_node { + struct oval_definition_model *model; oval_criteria_node_type_t type; int negate; char *comment; } oval_criteria_node_t; typedef struct oval_criteria_node_CRITERIA { + struct oval_definition_model *model; oval_criteria_node_type_t type; int negate; char *comment; @@ -49,6 +51,7 @@ } oval_criteria_node_CRITERIA_t; typedef struct oval_criteria_node_CRITERION { + struct oval_definition_model *model; oval_criteria_node_type_t type; int negate; char *comment; @@ -56,6 +59,7 @@ } oval_criteria_node_CRITERION_t; typedef struct oval_criteria_node_EXTENDDEF { + struct oval_definition_model *model; oval_criteria_node_type_t type; int negate; char *comment; @@ -136,7 +140,7 @@ ?((struct oval_criteria_node_EXTENDDEF *)node)->definition:NULL; } -struct oval_criteria_node *oval_criteria_node_new(oval_criteria_node_type_t type) +struct oval_criteria_node *oval_criteria_node_new(struct oval_definition_model* model, oval_criteria_node_type_t type) { struct oval_criteria_node *node; switch (type) { @@ -169,6 +173,7 @@ node->type = type; node->negate = 0; node->comment = NULL; + node->model = model; return node; } @@ -178,13 +183,13 @@ } bool oval_criteria_node_is_locked(struct oval_criteria_node *criteria_node) { - return false;//TODO + return oval_definition_model_is_locked(criteria_node->model); } struct oval_criteria_node *oval_criteria_node_clone - (struct oval_criteria_node *old_node, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_criteria_node *old_node) { - struct oval_criteria_node *new_node = oval_criteria_node_new(old_node->type); + struct oval_criteria_node *new_node = oval_criteria_node_new(new_model, old_node->type); char *comment = oval_criteria_node_get_comment(old_node); oval_criteria_node_set_comment(new_node, comment); int negate = oval_criteria_node_get_negate(old_node); @@ -197,18 +202,18 @@ struct oval_criteria_node_iterator *subnodes = oval_criteria_node_get_subnodes(old_node); while(oval_criteria_node_iterator_has_more(subnodes)){ struct oval_criteria_node *subnode = oval_criteria_node_iterator_next(subnodes); - oval_criteria_node_add_subnode(new_node, oval_criteria_node_clone(subnode, model)); + oval_criteria_node_add_subnode(new_node, oval_criteria_node_clone(new_model, subnode)); } oval_criteria_node_iterator_free(subnodes); }break; case OVAL_NODETYPE_EXTENDDEF:{ struct oval_definition *old_definition = oval_criteria_node_get_definition(old_node); - struct oval_definition *new_definition = oval_definition_clone(old_definition, model); + struct oval_definition *new_definition = oval_definition_clone(new_model, old_definition); oval_criteria_node_set_definition(new_node, new_definition); }break; case OVAL_NODETYPE_CRITERION:{ struct oval_test *old_test = oval_criteria_node_get_test(old_node); - struct oval_test *new_test = oval_test_clone(old_test, model); + struct oval_test *new_test = oval_test_clone(new_model, old_test); oval_criteria_node_set_test(new_node, new_test); }break; default: /*NOOP*/; @@ -247,59 +252,73 @@ void oval_criteria_set_node_type(struct oval_criteria_node *node, oval_criteria_node_type_t type) { - node->type = type; + if(node && !oval_criteria_node_is_locked(node)){ + node->type = type; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_set_negate(struct oval_criteria_node *node, bool negate) { - node->negate = negate; + if(node && !oval_criteria_node_is_locked(node)){ + node->negate = negate; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_set_comment(struct oval_criteria_node *node, char *comm) { - if(node->comment!=NULL)free(node->comment); - node->comment = comm==NULL?NULL:strdup(comm); + if(node && !oval_criteria_node_is_locked(node)){ + if(node->comment!=NULL)free(node->comment); + node->comment = comm==NULL?NULL:strdup(comm); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_set_operator(struct oval_criteria_node *node, oval_operator_t operator) { - if(node->type==OVAL_NODETYPE_CRITERIA){ - struct oval_criteria_node_CRITERIA *criteria = - (struct oval_criteria_node_CRITERIA *)node; - criteria->operator = operator; - } + if(node && !oval_criteria_node_is_locked(node)){ + if(node->type==OVAL_NODETYPE_CRITERIA){ + struct oval_criteria_node_CRITERIA *criteria = + (struct oval_criteria_node_CRITERIA *)node; + criteria->operator = operator; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_add_subnode(struct oval_criteria_node *node, struct oval_criteria_node *subnode) { - if(node->type==OVAL_NODETYPE_CRITERIA){ - struct oval_criteria_node_CRITERIA *criteria = - (struct oval_criteria_node_CRITERIA *)node; - oval_collection_add(criteria->subnodes, (void *)subnode); - } + if(node && !oval_criteria_node_is_locked(node)){ + if(node->type==OVAL_NODETYPE_CRITERIA){ + struct oval_criteria_node_CRITERIA *criteria = + (struct oval_criteria_node_CRITERIA *)node; + oval_collection_add(criteria->subnodes, (void *)subnode); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_set_test(struct oval_criteria_node *node, struct oval_test *test) { - if(node->type==OVAL_NODETYPE_CRITERION){ - struct oval_criteria_node_CRITERION *criterion = - (struct oval_criteria_node_CRITERION *)node; - criterion->test = test; - } + if(node && !oval_criteria_node_is_locked(node)){ + if(node->type==OVAL_NODETYPE_CRITERION){ + struct oval_criteria_node_CRITERION *criterion = + (struct oval_criteria_node_CRITERION *)node; + criterion->test = test; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_criteria_node_set_definition(struct oval_criteria_node *node, struct oval_definition *definition) { - if(node->type==OVAL_NODETYPE_EXTENDDEF){ - struct oval_criteria_node_EXTENDDEF *extenddef = - (struct oval_criteria_node_EXTENDDEF *)node; - extenddef->definition = definition; - } + if(node && !oval_criteria_node_is_locked(node)){ + if(node->type==OVAL_NODETYPE_EXTENDDEF){ + struct oval_criteria_node_EXTENDDEF *extenddef = + (struct oval_criteria_node_EXTENDDEF *)node; + extenddef->definition = definition; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_criteria_subnode_consume(struct oval_criteria_node *subnode, void *criteria) { @@ -333,7 +352,7 @@ type = OVAL_NODETYPE_EXTENDDEF; int return_code; if (type != OVAL_NODETYPE_UNKNOWN) { - struct oval_criteria_node *node = oval_criteria_node_new(type); + struct oval_criteria_node *node = oval_criteria_node_new(context->definition_model, type); node->type = type; char *comm = (char *) xmlTextReaderGetAttribute(reader, BAD_CAST "comment"); if(comm!=NULL){ diff -u -r a/src/OVAL/oval_definition.c b/src/OVAL/oval_definition.c --- a/src/OVAL/oval_definition.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_definition.c 2009-12-11 13:30:25 -0500 @@ -38,6 +38,7 @@ #include "../common/util.h" typedef struct oval_definition { + struct oval_definition_model *model; char *id; int version; oval_definition_class_t class; @@ -108,7 +109,7 @@ return ((struct oval_definition *)definition)->criteria; } -struct oval_definition *oval_definition_new(char *id) +struct oval_definition *oval_definition_new(struct oval_definition_model* model, char *id) { struct oval_definition *definition = (struct oval_definition *)malloc(sizeof(oval_definition_t)); @@ -122,6 +123,7 @@ definition->reference = oval_collection_new(); definition->notes = oval_collection_new(); definition->criteria = NULL; + definition->model = model; return definition; } bool oval_definition_is_valid(struct oval_definition *definition) @@ -130,19 +132,15 @@ } bool oval_definition_is_locked(struct oval_definition *definition) { - return false;//TODO -} -void oval_definition_model_set_locked(struct oval_definition_model * model) -{ - return; + return oval_definition_model_is_locked(definition->model); } struct oval_definition *oval_definition_clone - (struct oval_definition *old_definition, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_definition *old_definition) { - struct oval_definition *new_definition = oval_definition_model_get_definition(model, old_definition->id); + struct oval_definition *new_definition = oval_definition_model_get_definition(new_model, old_definition->id); if(new_definition==NULL){ - new_definition = oval_definition_new(old_definition->id); + new_definition = oval_definition_new(new_model, old_definition->id); oval_definition_set_version (new_definition, old_definition->version); oval_definition_set_class (new_definition, old_definition->class); oval_definition_set_deprecated (new_definition, old_definition->deprecated); @@ -152,13 +150,13 @@ struct oval_affected_iterator *affecteds = oval_definition_get_affected(old_definition); while(oval_affected_iterator_has_more(affecteds)){ struct oval_affected *old_affected = oval_affected_iterator_next(affecteds); - oval_definition_add_affected(new_definition, oval_affected_clone(old_affected)); + oval_definition_add_affected(new_definition, oval_affected_clone(new_model, old_affected)); } oval_affected_iterator_free(affecteds); struct oval_reference_iterator *references = oval_definition_get_references(old_definition); while(oval_reference_iterator_has_more(references)){ struct oval_reference *old_reference = oval_reference_iterator_next(references); - oval_definition_add_reference(new_definition, oval_reference_clone(old_reference)); + oval_definition_add_reference(new_definition, oval_reference_clone(new_model, old_reference)); } oval_reference_iterator_free(references); struct oval_string_iterator *notes = oval_definition_get_notes(old_definition); @@ -168,9 +166,9 @@ } oval_string_iterator_free(notes); - oval_definition_set_criteria(new_definition, oval_criteria_node_clone(old_definition->criteria, model)); + oval_definition_set_criteria(new_definition, oval_criteria_node_clone(new_model, old_definition->criteria)); - oval_definition_model_add_definition(model, new_definition); + oval_definition_model_add_definition(new_model, new_definition); } return new_definition; } @@ -225,56 +223,74 @@ void oval_definition_set_version(struct oval_definition *definition, int version) { - definition->version = version; + if(definition && !oval_definition_is_locked(definition)){ + definition->version = version; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_set_class(struct oval_definition *definition, oval_definition_class_t class) { - definition->class = class; + if(definition && !oval_definition_is_locked(definition)){ + definition->class = class; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_set_deprecated(struct oval_definition *definition, bool deprecated) { - definition->deprecated = deprecated; + if(definition && !oval_definition_is_locked(definition)){ + definition->deprecated = deprecated; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_set_title(struct oval_definition *definition, char *title) { - if(definition->title!=NULL)free(definition->title); - definition->title = title==NULL?NULL:strdup(title); + if(definition && !oval_definition_is_locked(definition)){ + if(definition->title!=NULL)free(definition->title); + definition->title = title==NULL?NULL:strdup(title); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_set_description(struct oval_definition *definition, char *description) { - if(definition->description)free(definition->description); - definition->description = description==NULL?NULL:strdup(description); + if(definition && !oval_definition_is_locked(definition)){ + if(definition->description)free(definition->description); + definition->description = description==NULL?NULL:strdup(description); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_set_criteria(struct oval_definition *definition, struct oval_criteria_node *criteria) { - definition->criteria = criteria; + if(definition && !oval_definition_is_locked(definition)){ + definition->criteria = criteria; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_add_affected(struct oval_definition *definition, struct oval_affected *affected) { - oval_collection_add(definition->affected, affected); + if(definition && !oval_definition_is_locked(definition)){ + oval_collection_add(definition->affected, affected); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_add_reference(struct oval_definition *definition, struct oval_reference *ref) { - oval_collection_add(definition->reference, ref); + if(definition && !oval_definition_is_locked(definition)){ + oval_collection_add(definition->reference, ref); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_definition_add_note (struct oval_definition *definition, char *note) { - oval_collection_add(definition->notes, note); + if(definition && !oval_definition_is_locked(definition)){ + oval_collection_add(definition->notes, note); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static const struct oscap_string_map OVAL_DEFINITION_CLASS_MAP[] = { diff -u -r a/src/OVAL/oval_entity.c b/src/OVAL/oval_entity.c --- a/src/OVAL/oval_entity.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_entity.c 2009-12-11 13:30:45 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" struct oval_entity { + struct oval_definition_model *model; oval_entity_type_t type; oval_datatype_t datatype; oval_operation_t operation; @@ -105,7 +106,7 @@ return entity->value; } -struct oval_entity *oval_entity_new() +struct oval_entity *oval_entity_new(struct oval_definition_model* model) { struct oval_entity *entity = (struct oval_entity *)malloc(sizeof(struct oval_entity)); @@ -116,6 +117,7 @@ entity->name = NULL; entity->value = NULL; entity->variable = NULL; + entity->model = model; return entity; } @@ -125,13 +127,13 @@ } bool oval_entity_is_locked(struct oval_entity *entity) { - return false;//TODO + return oval_definition_model_is_locked(entity->model); } struct oval_entity *oval_entity_clone - (struct oval_entity *old_entity, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_entity *old_entity) { - struct oval_entity *new_entity = oval_entity_new(); + struct oval_entity *new_entity = oval_entity_new(new_model); oval_datatype_t datatype = oval_entity_get_datatype(old_entity); oval_entity_set_datatype(new_entity, datatype); int mask = oval_entity_get_mask(old_entity); @@ -146,7 +148,7 @@ oval_entity_set_value(new_entity, oval_value_clone(value)); struct oval_variable *old_variable = oval_entity_get_variable(old_entity); if(old_variable){ - struct oval_variable *new_variable = oval_variable_clone(old_variable, model); + struct oval_variable *new_variable = oval_variable_clone(new_model, old_variable); oval_entity_set_variable(new_entity, new_variable); } oval_entity_varref_type_t reftype = oval_entity_get_varref_type(old_entity); @@ -171,47 +173,63 @@ void oval_entity_set_type(struct oval_entity *entity, oval_entity_type_t type) { - entity->type = type; + if(entity && !oval_entity_is_locked(entity)){ + entity->type = type; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_datatype(struct oval_entity *entity, oval_datatype_t datatype) { - entity->datatype = datatype; + if(entity && !oval_entity_is_locked(entity)){ + entity->datatype = datatype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_operation(struct oval_entity *entity, oval_operation_t operation) { - entity->operation = operation; + if(entity && !oval_entity_is_locked(entity)){ + entity->operation = operation; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_mask(struct oval_entity *entity, int mask) { - entity->mask = mask; + if(entity && !oval_entity_is_locked(entity)){ + entity->mask = mask; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_varref_type(struct oval_entity *entity, oval_entity_varref_type_t type) { - entity->varref_type = type; + if(entity && !oval_entity_is_locked(entity)){ + entity->varref_type = type; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_variable(struct oval_entity *entity, struct oval_variable *variable) { - entity->variable = variable; + if(entity && !oval_entity_is_locked(entity)){ + entity->variable = variable; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_value(struct oval_entity *entity, struct oval_value *value) { - entity->value = value; + if(entity && !oval_entity_is_locked(entity)){ + entity->value = value; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_entity_set_name(struct oval_entity *entity, char *name) { - if(entity->name!=NULL)free(entity->name); - entity->name = name==NULL?NULL:strdup(name); + if(entity && !oval_entity_is_locked(entity)){ + if(entity->name!=NULL)free(entity->name); + entity->name = name==NULL?NULL:strdup(name); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_consume_varref_context { @@ -231,7 +249,7 @@ struct oval_parser_context *context, oscap_consumer_func consumer, void *user) { - struct oval_entity *entity = oval_entity_new(); + struct oval_entity *entity = oval_entity_new(context->definition_model); int return_code; oval_datatype_t datatype = oval_datatype_parse(reader, "datatype", OVAL_DATATYPE_STRING); diff -u -r a/src/OVAL/oval_message.c b/src/OVAL/oval_message.c --- a/src/OVAL/oval_message.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_message.c 2009-12-10 11:47:28 -0500 @@ -37,6 +37,7 @@ static int DEBUG_OVAL_MESSAGE = 0; typedef struct oval_message { + void *model; char* text; oval_message_level_t level; } oval_message_t; @@ -102,12 +103,16 @@ void oval_message_set_text(struct oval_message *message, char *text) { - if(message->text!=NULL)free(message->text); - message->text = (text==NULL)?NULL:strdup(text); + if(message && !oval_message_is_locked(message)){ + if(message->text!=NULL)free(message->text); + message->text = (text==NULL)?NULL:strdup(text); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_message_set_level(struct oval_message *message, oval_message_level_t level) { - message->level = level; + if(message && !oval_message_is_locked(message)){ + message->level = level; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void oval_message_parse_tag_consumer(char* text, void* message){ diff -u -r a/src/OVAL/oval_object.c b/src/OVAL/oval_object.c --- a/src/OVAL/oval_object.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_object.c 2009-12-11 13:31:23 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_object { + struct oval_definition_model *model; oval_subtype_t subtype; struct oval_collection *notes; char *comment; @@ -118,7 +119,7 @@ oval_collection_iterator(object->behaviors); } -struct oval_object *oval_object_new(char *id) +struct oval_object *oval_object_new(struct oval_definition_model* model, char *id) { oval_object_t *object = (oval_object_t *) malloc(sizeof(oval_object_t)); object->comment = NULL; @@ -129,6 +130,7 @@ object->behaviors = oval_collection_new(); object->notes = oval_collection_new(); object->object_content = oval_collection_new(); + object->model = model; return object; } @@ -138,15 +140,15 @@ } bool oval_object_is_locked(struct oval_object *object) { - return false;//TODO + return oval_definition_model_is_locked(object->model); } struct oval_object *oval_object_clone - (struct oval_object *old_object, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_object *old_object) { - struct oval_object *new_object = oval_definition_model_get_object(model, old_object->id); + struct oval_object *new_object = oval_definition_model_get_object(new_model, old_object->id); if(new_object==NULL){ - new_object = oval_object_new(old_object->id); + new_object = oval_object_new(new_model, old_object->id); oval_object_set_comment (new_object, old_object->comment); oval_object_set_subtype (new_object, old_object->subtype); oval_object_set_deprecated(new_object, old_object->deprecated); @@ -155,7 +157,7 @@ struct oval_behavior_iterator *behaviors = oval_object_get_behaviors(old_object); while(oval_behavior_iterator_has_more(behaviors)){ struct oval_behavior *behavior = oval_behavior_iterator_next(behaviors); - oval_object_add_behavior(new_object, oval_behavior_clone(behavior)); + oval_object_add_behavior(new_object, oval_behavior_clone(new_model, behavior)); } oval_behavior_iterator_free(behaviors); struct oval_string_iterator *notes = oval_object_get_notes(old_object); @@ -167,11 +169,11 @@ struct oval_object_content_iterator *object_contents = oval_object_get_object_contents(old_object); while(oval_object_content_iterator_has_more(object_contents)){ struct oval_object_content *object_content = oval_object_content_iterator_next(object_contents); - oval_object_add_object_content(new_object, oval_object_content_clone(object_content, model)); + oval_object_add_object_content(new_object, oval_object_content_clone(new_model, object_content)); } oval_object_content_iterator_free(object_contents); - oval_definition_model_add_object(model, new_object); + oval_definition_model_add_object(new_model, new_object); } return new_object; } @@ -197,40 +199,54 @@ void oval_object_set_subtype(struct oval_object *object, oval_subtype_t subtype) { - object->subtype = subtype; + if(object && !oval_object_is_locked(object)){ + object->subtype = subtype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_add_note(struct oval_object *object, char *note) { - oval_collection_add(object->notes, (void *)strdup(note)); + if(object && !oval_object_is_locked(object)){ + oval_collection_add(object->notes, (void *)strdup(note)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_set_comment(struct oval_object *object, char *comm) { - if(object->comment!=NULL)free(object->comment); - object->comment = comm==NULL?NULL:strdup(comm); + if(object && !oval_object_is_locked(object)){ + if(object->comment!=NULL)free(object->comment); + object->comment = comm==NULL?NULL:strdup(comm); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_set_deprecated(struct oval_object *object, bool deprecated) { - object->deprecated = deprecated; + if(object && !oval_object_is_locked(object)){ + object->deprecated = deprecated; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_set_version(struct oval_object *object, int version) { - object->version = version; + if(object && !oval_object_is_locked(object)){ + object->version = version; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_add_object_content(struct oval_object *object, struct oval_object_content *content) { - oval_collection_add(object->object_content, (void *)content); + if(object && !oval_object_is_locked(object)){ + oval_collection_add(object->object_content, (void *)content); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_add_behavior(struct oval_object *object, struct oval_behavior *behavior) { - oval_collection_add(object->behaviors, (void *)behavior); + if(object && !oval_object_is_locked(object)){ + oval_collection_add(object->behaviors, (void *)behavior); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void oval_note_consume(char *text, void *object) { diff -u -r a/src/OVAL/oval_objectContent.c b/src/OVAL/oval_objectContent.c --- a/src/OVAL/oval_objectContent.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_objectContent.c 2009-12-11 13:48:23 -0500 @@ -35,11 +35,13 @@ #include "oval_agent_api_impl.h" typedef struct oval_object_content { + struct oval_definition_model *model; char *fieldName; oval_object_content_type_t type; } oval_object_content_t; typedef struct oval_object_content_ENTITY { + struct oval_definition_model *model; char *fieldName; oval_object_content_type_t type; struct oval_entity *entity; //type == OVAL_OBJECTCONTENT_ENTITY @@ -47,6 +49,7 @@ } oval_object_content_ENTITY_t; typedef struct oval_object_content_SET { + struct oval_definition_model *model; char *fieldName; oval_object_content_type_t type; struct oval_setobject *set; //type == OVAL_OBJECTCONTENT_SET @@ -122,7 +125,7 @@ } struct oval_object_content - *oval_object_content_new(oval_object_content_type_t type) + *oval_object_content_new(struct oval_definition_model *model, oval_object_content_type_t type) { struct oval_object_content *content = NULL; switch (type) { @@ -147,6 +150,7 @@ break; case OVAL_OBJECTCONTENT_UNKNOWN: break; } + content->model = model; content->fieldName = NULL; content->type = type; return content; @@ -158,14 +162,14 @@ } bool oval_object_content_is_locked(struct oval_object_content *object_content) { - return false;//TODO + return oval_definition_model_is_locked(object_content->model); } struct oval_object_content *oval_object_content_clone - (struct oval_object_content *old_content, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_object_content *old_content) { struct oval_object_content *new_content - = oval_object_content_new(old_content->type); + = oval_object_content_new(new_model, old_content->type); char *name = oval_object_content_get_field_name(old_content); oval_object_content_set_field_name(new_content, name); switch(new_content->type){ @@ -177,7 +181,7 @@ }break; case OVAL_OBJECTCONTENT_SET:{ struct oval_setobject *set = oval_object_content_get_setobject(old_content); - oval_object_content_set_setobject(new_content, oval_setobject_clone(set, model)); + oval_object_content_set_setobject(new_content, oval_setobject_clone(new_model, set)); } default: /*NOOP*/; } @@ -211,33 +215,43 @@ } void oval_object_content_set_type(struct oval_object_content *content, oval_object_content_type_t type) { - content->type = type; + if(content && !oval_object_content_is_locked(content)){ + content->type = type; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_content_set_field_name(struct oval_object_content *content, char *name) { - if(content->fieldName!=NULL)free(content->fieldName); - content->fieldName = name==NULL?NULL:strdup(name); + if(content && !oval_object_content_is_locked(content)){ + if(content->fieldName!=NULL)free(content->fieldName); + content->fieldName = name==NULL?NULL:strdup(name); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_content_set_entity(struct oval_object_content *content, struct oval_entity *entity)//type == OVAL_OBJECTCONTENT_ENTITY { - if(content->type == OVAL_OBJECTCONTENT_ENTITY){ - oval_object_content_ENTITY_t *content_ENTITY = (oval_object_content_ENTITY_t *)content; - content_ENTITY->entity = entity; - } + if(content && !oval_object_content_is_locked(content)){ + if(content->type == OVAL_OBJECTCONTENT_ENTITY){ + oval_object_content_ENTITY_t *content_ENTITY = (oval_object_content_ENTITY_t *)content; + content_ENTITY->entity = entity; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_content_set_varCheck(struct oval_object_content *content, oval_check_t check)//type == OVAL_OBJECTCONTENT_ENTITY { - if(content->type == OVAL_OBJECTCONTENT_ENTITY){ - oval_object_content_ENTITY_t *content_ENTITY = (oval_object_content_ENTITY_t *)content; - content_ENTITY->varCheck = check; - } + if(content && !oval_object_content_is_locked(content)){ + if(content->type == OVAL_OBJECTCONTENT_ENTITY){ + oval_object_content_ENTITY_t *content_ENTITY = (oval_object_content_ENTITY_t *)content; + content_ENTITY->varCheck = check; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_object_content_set_setobject(struct oval_object_content *content, struct oval_setobject *set)//type == OVAL_OBJECTCONTENT_SET { - if(content->type == OVAL_OBJECTCONTENT_SET){ - oval_object_content_SET_t *content_SET = (oval_object_content_SET_t *)content; - content_SET->set = set; - } + if(content && !oval_object_content_is_locked(content)){ + if(content->type == OVAL_OBJECTCONTENT_SET){ + oval_object_content_SET_t *content_SET = (oval_object_content_SET_t *)content; + content_SET->set = set; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //typedef void (*oval_object_content_consumer)(struct oval_object_content*,void*); @@ -259,7 +273,7 @@ oval_object_content_type_t type = (strcmp(tagname, "set") == 0) ? OVAL_OBJECTCONTENT_SET : OVAL_OBJECTCONTENT_ENTITY; - struct oval_object_content *content = oval_object_content_new(type); + struct oval_object_content *content = oval_object_content_new(context->definition_model, type); content->fieldName = tagname; int return_code = 0; switch (type) { diff -u -r a/src/OVAL/oval_probe.c b/src/OVAL/oval_probe.c --- a/src/OVAL/oval_probe.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_probe.c 2009-12-11 16:29:06 -0500 @@ -202,7 +202,7 @@ ctx->p_dir = strdup (va_arg (ap, const char *)); break; case OVAL_PCTX_ATTR_MODEL: - ctx->model = va_arg (ap, struct oval_syschar_model *); + ctx->sys = va_arg (ap, struct oval_syschar_model *); break; } @@ -414,7 +414,8 @@ * Convert the received S-exp to OVAL system characteristic. */ - o_sysc = oval_sexp2sysch (s_sysc, object); + struct oval_syschar_model *model = ctx->model; + o_sysc = oval_sexp2sysch (s_sysc, model, object); SEXP_free (s_sysc); SEXP_free (s_obj); diff -u -r a/src/OVAL/oval_reference.c b/src/OVAL/oval_reference.c --- a/src/OVAL/oval_reference.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_reference.c 2009-12-11 13:31:56 -0500 @@ -34,6 +34,7 @@ #include "oval_collection_impl.h" typedef struct oval_reference { + struct oval_definition_model *model; char *source; char *id; char *url; @@ -76,13 +77,14 @@ return ((struct oval_reference *)ref)->url; } -struct oval_reference *oval_reference_new() +struct oval_reference *oval_reference_new(struct oval_definition_model* model) { struct oval_reference *ref = (struct oval_reference *)malloc(sizeof(oval_reference_t)); ref->id = NULL; ref->source = NULL; ref->url = NULL; + ref->model = model; return ref; } @@ -92,13 +94,13 @@ } bool oval_reference_is_locked(struct oval_reference *reference) { - return false;//TODO + return oval_definition_model_is_locked(reference->model); } struct oval_reference *oval_reference_clone - (struct oval_reference *old_reference) + (struct oval_definition_model *new_model, struct oval_reference *old_reference) { - struct oval_reference *new_reference = oval_reference_new(); + struct oval_reference *new_reference = oval_reference_new(new_model); char *id = oval_reference_get_id(old_reference); oval_reference_set_id(new_reference, id); char *source = oval_reference_get_source(old_reference); @@ -124,20 +126,26 @@ void oval_reference_set_source(struct oval_reference *ref, char *source) { - if(ref->source!=NULL)free(ref->source); - ref->source = ref->source==NULL?NULL:source; + if(ref && !oval_reference_is_locked(ref)){ + if(ref->source!=NULL)free(ref->source); + ref->source = ref->source==NULL?NULL:source; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_reference_set_id(struct oval_reference *ref, char *id) { - if(ref->id!=NULL)free(ref->id); - ref->id = id==NULL?NULL:strdup(id); + if(ref && !oval_reference_is_locked(ref)){ + if(ref->id!=NULL)free(ref->id); + ref->id = id==NULL?NULL:strdup(id); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_reference_set_url(struct oval_reference *ref, char *url) { - if(ref->url!=NULL)free(ref->url); - ref->url = url==NULL?NULL:strdup(url); + if(ref && !oval_reference_is_locked(ref)){ + if(ref->url!=NULL)free(ref->url); + ref->url = url==NULL?NULL:strdup(url); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //typedef void (*oval_reference_consumer)(struct oval_reference*, void*); @@ -145,7 +153,7 @@ struct oval_parser_context *context, oval_reference_consumer consumer, void *user) { - struct oval_reference *ref = oval_reference_new(); + struct oval_reference *ref = oval_reference_new(context->definition_model); char *ref_id = (char*) xmlTextReaderGetAttribute(reader, BAD_CAST "ref_id"); if(ref_id!=NULL){ oval_reference_set_id(ref, ref_id); diff -u -r a/src/OVAL/oval_resultCriteriaNode.c b/src/OVAL/oval_resultCriteriaNode.c --- a/src/OVAL/oval_resultCriteriaNode.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultCriteriaNode.c 2009-12-11 14:05:43 -0500 @@ -37,12 +37,14 @@ #define DEBUG_RESULT_CRITERIA_NODE 0 typedef struct oval_result_criteria_node { + struct oval_result_system *sys; oval_criteria_node_type_t type; oval_result_t result; int negate; } oval_result_criteria_node_t; typedef struct oval_result_criteria_node_CRITERIA { + struct oval_result_system *sys; oval_criteria_node_type_t type; oval_result_t result; int negate; @@ -51,6 +53,7 @@ } oval_result_criteria_node_CRITERIA_t; typedef struct oval_result_criteria_node_CRITERION { + struct oval_result_system *sys; oval_criteria_node_type_t type; oval_result_t result; int negate; @@ -59,6 +62,7 @@ } oval_result_criteria_node_CRITERION_t; typedef struct oval_result_criteria_node_EXTENDDEF { + struct oval_result_system *sys; oval_criteria_node_type_t type; oval_result_t result; int negate; @@ -69,7 +73,7 @@ struct oval_result_criteria_node *oval_result_criteria_node_new - (oval_criteria_node_type_t type, int negate, ...) + (struct oval_result_system* sys, oval_criteria_node_type_t type, int negate, ...) { oval_result_criteria_node_t *node = NULL; va_list ap; @@ -104,6 +108,7 @@ }break; default: break; } + node->sys = sys; node->negate = negate; node->result = OVAL_RESULT_INVALID; node->type = type; @@ -117,11 +122,11 @@ } bool oval_result_criteria_node_is_locked(struct oval_result_criteria_node *result_criteria_node) { - return false;//TODO + return oval_result_system_is_locked(result_criteria_node->sys); } struct oval_result_criteria_node *oval_result_criteria_node_clone - (struct oval_result_criteria_node *old_node, struct oval_result_system *new_system) + (struct oval_result_system *new_system, struct oval_result_criteria_node *old_node) { oval_criteria_node_type_t type = oval_result_criteria_node_get_type(old_node); struct oval_result_criteria_node *new_node = NULL; @@ -130,24 +135,24 @@ { case OVAL_NODETYPE_CRITERIA:{ oval_operator_t operator = oval_result_criteria_node_get_operator(old_node); - new_node = oval_result_criteria_node_new(OVAL_NODETYPE_CRITERIA, negate, operator); + new_node = oval_result_criteria_node_new(new_system, OVAL_NODETYPE_CRITERIA, negate, operator); struct oval_result_criteria_node_iterator *old_subs = oval_result_criteria_node_get_subnodes(old_node); while(oval_result_criteria_node_iterator_has_more(old_subs)){ struct oval_result_criteria_node *old_sub = oval_result_criteria_node_iterator_next(old_subs); - struct oval_result_criteria_node *new_sub = oval_result_criteria_node_clone(old_sub, new_system); + struct oval_result_criteria_node *new_sub = oval_result_criteria_node_clone(new_system, old_sub); oval_result_criteria_node_add_subnode(new_node, new_sub); } oval_result_criteria_node_iterator_free(old_subs); };break; case OVAL_NODETYPE_CRITERION:{ struct oval_result_test *old_test = oval_result_criteria_node_get_test(old_node); - struct oval_result_test *new_test = oval_result_test_clone(old_test, new_system); - new_node = oval_result_criteria_node_new(OVAL_NODETYPE_CRITERION, negate, new_test, 1); + struct oval_result_test *new_test = oval_result_test_clone(new_system, old_test); + new_node = oval_result_criteria_node_new(new_system, OVAL_NODETYPE_CRITERION, negate, new_test, 1); };break; case OVAL_NODETYPE_EXTENDDEF:{ struct oval_result_definition *old_def = oval_result_criteria_node_get_extends(old_node); - struct oval_result_definition *new_def = oval_result_definition_clone(old_def, new_system); - new_node = oval_result_criteria_node_new(OVAL_NODETYPE_EXTENDDEF, negate, new_def, 1); + struct oval_result_definition *new_def = oval_result_definition_clone(new_system, old_def); + new_node = oval_result_criteria_node_new(new_system, OVAL_NODETYPE_EXTENDDEF, negate, new_def, 1); }break; default: break; } @@ -195,7 +200,7 @@ oval_operator_t operator = oval_criteria_node_get_operator(oval_node); rslt_node - = oval_result_criteria_node_new(type, negate, operator); + = oval_result_criteria_node_new(sys, type, negate, operator); struct oval_criteria_node_iterator *oval_subnodes = oval_criteria_node_get_subnodes(oval_node); while(oval_criteria_node_iterator_has_more(oval_subnodes)){ @@ -214,7 +219,7 @@ struct oval_result_test *rslt_test = get_oval_result_test_new(sys, oval_test); rslt_node - = oval_result_criteria_node_new(type, negate, rslt_test, 0); + = oval_result_criteria_node_new(sys, type, negate, rslt_test, 0); }break; case OVAL_NODETYPE_EXTENDDEF:{ struct oval_definition *oval_definition @@ -222,7 +227,7 @@ struct oval_result_definition *rslt_definition = oval_result_system_get_new_definition(sys, oval_definition); rslt_node - = oval_result_criteria_node_new(type, negate, rslt_definition, 0); + = oval_result_criteria_node_new(sys, type, negate, rslt_definition, 0); }break; default: rslt_node = NULL; } @@ -259,7 +264,8 @@ oval_result_criteria_node *node) { - return ((struct oval_result_criteria_node *)node)->type; + oval_criteria_node_type_t type = ((struct oval_result_criteria_node *)node)->type; + return type; } static oval_result_t _oval_result_negate(bool negate, oval_result_t result) @@ -437,55 +443,67 @@ void oval_result_criteria_node_set_result (struct oval_result_criteria_node *node, oval_result_t result) { - node->result = result; + if(node && !oval_result_criteria_node_is_locked(node)){ + node->result = result; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_criteria_node_set_negate (struct oval_result_criteria_node *node, bool negate) { - node->negate = negate; + if(node && !oval_result_criteria_node_is_locked(node)){ + node->negate = negate; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_criteria_node_set_operator (struct oval_result_criteria_node *node, oval_operator_t operator) { - //type==NODETYPE_CRITERIA - if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERIA) { - ((struct oval_result_criteria_node_CRITERIA *)node)-> - operator = operator; - } + if(node && !oval_result_criteria_node_is_locked(node)){ + //type==NODETYPE_CRITERIA + if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERIA) { + ((struct oval_result_criteria_node_CRITERIA *)node)-> + operator = operator; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_criteria_node_add_subnode (struct oval_result_criteria_node *node, struct oval_result_criteria_node *subnode ) { - //type==NODETYPE_CRITERIA - if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERIA) { - struct oval_result_criteria_node_CRITERIA *criteria - = ((struct oval_result_criteria_node_CRITERIA *)node); - oval_collection_add(criteria->subnodes, subnode); - } + if(node && !oval_result_criteria_node_is_locked(node)){ + //type==NODETYPE_CRITERIA + if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERIA) { + struct oval_result_criteria_node_CRITERIA *criteria + = ((struct oval_result_criteria_node_CRITERIA *)node); + oval_collection_add(criteria->subnodes, subnode); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_criteria_node_set_test (struct oval_result_criteria_node *node, struct oval_result_test *test) { - //type==NODETYPE_CRITERION - if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERION) { - ((struct oval_result_criteria_node_CRITERION *)node)-> - test = test; - } + if(node && !oval_result_criteria_node_is_locked(node)){ + //type==NODETYPE_CRITERION + if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_CRITERION) { + ((struct oval_result_criteria_node_CRITERION *)node)-> + test = test; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_criteria_node_set_extends (struct oval_result_criteria_node *node, struct oval_result_definition *extends) { - //type==NODETYPE_EXTENDDEF - if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_EXTENDDEF) { - extends = - ((struct oval_result_criteria_node_EXTENDDEF *)node)-> - extends = extends; - } + if(node && !oval_result_criteria_node_is_locked(node)){ + //type==NODETYPE_EXTENDDEF + if (oval_result_criteria_node_get_type(node) == OVAL_NODETYPE_EXTENDDEF) { + extends = + ((struct oval_result_criteria_node_EXTENDDEF *)node)-> + extends = extends; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_result_criteria_consume_subnode @@ -525,7 +543,7 @@ oval_operator_t operator = oval_operator_parse (reader, "operator",OVAL_OPERATOR_UNKNOWN); int negate = oval_parser_boolean_attribute(reader, "negate", false); - node = oval_result_criteria_node_new(OVAL_NODETYPE_CRITERIA, negate, operator); + node = oval_result_criteria_node_new(sys, OVAL_NODETYPE_CRITERIA, negate, operator); void *args[] = {sys, node}; return_code = oval_parser_parse_tag (reader, context, @@ -557,7 +575,7 @@ oval_parser_log_warn(context, message); } node = oval_result_criteria_node_new - (OVAL_NODETYPE_CRITERION, negate, rslt_test, variable_instance); + (sys, OVAL_NODETYPE_CRITERION, negate, rslt_test, variable_instance); return_code = 1; free(test_ref); }else if(strcmp((const char *)localName, "extend_definition")==0){ @@ -574,7 +592,7 @@ ?oval_result_system_get_new_definition(sys, oval_definition):NULL; node = (rslt_definition) ?oval_result_criteria_node_new - (OVAL_NODETYPE_EXTENDDEF, negate, rslt_definition, variable_instance):NULL; + (sys, OVAL_NODETYPE_EXTENDDEF, negate, rslt_definition, variable_instance):NULL; return_code = 1; free(definition_ref); }else{ diff -u -r a/src/OVAL/oval_resultDefinition.c b/src/OVAL/oval_resultDefinition.c --- a/src/OVAL/oval_resultDefinition.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultDefinition.c 2009-12-11 11:41:37 -0500 @@ -87,18 +87,20 @@ } bool oval_result_definition_is_locked(struct oval_result_definition *result_definition) { - return false;//TODO + return oval_result_system_is_locked(result_definition->system); } struct oval_result_definition *oval_result_definition_clone - (struct oval_result_definition *old_definition, struct oval_result_system *new_system) + (struct oval_result_system *new_system, struct oval_result_definition *old_definition) { struct oval_definition *ovaldef = oval_result_definition_get_definition(old_definition); struct oval_result_definition *new_definition = oval_result_definition_new(new_system, oval_definition_get_id(ovaldef)); struct oval_result_criteria_node *old_crit = oval_result_definition_get_criteria(old_definition); - struct oval_result_criteria_node *new_crit = oval_result_criteria_node_clone(old_crit, new_system); - oval_result_definition_set_criteria(new_definition, new_crit); + if(old_crit){ + struct oval_result_criteria_node *new_crit = oval_result_criteria_node_clone(new_system, old_crit); + oval_result_definition_set_criteria(new_definition, new_crit); + } struct oval_message_iterator *old_messages = oval_result_definition_get_messages(old_definition); while(oval_message_iterator_has_more(old_messages)){ @@ -192,32 +194,40 @@ void oval_result_definition_set_result (struct oval_result_definition *definition, oval_result_t result) { - definition->result = result; + if(definition && !oval_result_definition_is_locked(definition)){ + definition->result = result; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_definition_set_instance (struct oval_result_definition *definition, int instance) { - definition->instance = instance; + if(definition && !oval_result_definition_is_locked(definition)){ + definition->instance = instance; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_definition_set_criteria (struct oval_result_definition *definition, struct oval_result_criteria_node *criteria) { - if(definition->criteria){ - if(oval_result_criteria_node_get_type(criteria)==OVAL_NODETYPE_CRITERIA){ - oval_result_criteria_node_free(definition->criteria); + if(definition && !oval_result_definition_is_locked(definition)){ + if(definition->criteria){ + if(oval_result_criteria_node_get_type(criteria)==OVAL_NODETYPE_CRITERIA){ + oval_result_criteria_node_free(definition->criteria); + } } - } - definition->criteria = criteria; + definition->criteria = criteria; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_definition_add_message (struct oval_result_definition *definition, struct oval_message *message) { - if(message)oval_collection_add(definition->messages, message); + if(definition && !oval_result_definition_is_locked(definition)){ + if(message)oval_collection_add(definition->messages, message); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_result_definition_consume_criteria diff -u -r a/src/OVAL/oval_resultDirectives.c b/src/OVAL/oval_resultDirectives.c --- a/src/OVAL/oval_resultDirectives.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultDirectives.c 2009-12-11 13:49:53 -0500 @@ -44,10 +44,11 @@ #define NUMBER_OF_RESULTS 7 typedef struct oval_result_directives { + struct oval_results_model *model; struct _oval_result_directive directive[NUMBER_OF_RESULTS]; } oval_result_directives_t; -struct oval_result_directives *oval_result_directives_new() +struct oval_result_directives *oval_result_directives_new(struct oval_results_model* model) { oval_result_directives_t *directives = (oval_result_directives_t *) malloc(sizeof(oval_result_directives_t)); @@ -55,6 +56,7 @@ directives->directive[i].reported = false; directives->directive[i].content = OVAL_DIRECTIVE_CONTENT_UNKNOWN; } + directives->model = model; return directives; } @@ -64,7 +66,7 @@ } bool oval_result_directives_is_locked(struct oval_result_directives *result_directives) { - return false;//TODO + return oval_results_model_is_locked(result_directives->model); } void oval_result_directives_free(struct oval_result_directives *directives) @@ -85,12 +87,16 @@ void oval_result_directives_set_reported (struct oval_result_directives *directives, oval_result_t type, bool reported) { - directives->directive[type].reported = reported; + if(directives && !oval_result_directives_is_locked(directives)){ + directives->directive[type].reported = reported; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_directives_set_content (struct oval_result_directives *directives, oval_result_t type, oval_result_directive_content_t content) { - directives->directive[type].content = content; + if(directives && !oval_result_directives_is_locked(directives)){ + directives->directive[type].content = content; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //typedef int (*oval_xml_tag_parser) (xmlTextReaderPtr, struct oval_parser_context *, void *); diff -u -r a/src/OVAL/oval_resultItem.c b/src/OVAL/oval_resultItem.c --- a/src/OVAL/oval_resultItem.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultItem.c 2009-12-11 13:51:48 -0500 @@ -36,6 +36,7 @@ #define OVAL_RESULT_ITEM_DEBUG 0 typedef struct oval_result_item { + struct oval_result_system *sys; oval_result_t result; struct oval_collection *messages; struct oval_sysdata *sysdata; @@ -52,6 +53,7 @@ item->sysdata = sysdata; item->messages = oval_collection_new(); item->result = 0; + item->sys = sys; return item; } @@ -62,11 +64,11 @@ } bool oval_result_item_is_locked(struct oval_result_item *result_item) { - return false;//TODO + return oval_result_system_is_locked(result_item->sys); } struct oval_result_item *oval_result_item_clone - (struct oval_result_item *old_item, struct oval_result_system *new_system) + (struct oval_result_system *new_system, struct oval_result_item *old_item) { struct oval_sysdata *old_sysdata = oval_result_item_get_sysdata(old_item); char *datid = oval_sysdata_get_id(old_sysdata); @@ -138,13 +140,17 @@ void oval_result_item_set_result(struct oval_result_item *item, oval_result_t result) { - item->result = result; + if(item && !oval_result_item_is_locked(item)){ + item->result = result; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_item_add_message (struct oval_result_item *item, struct oval_message *message) { - oval_collection_add(item->messages, message); + if(item && !oval_result_item_is_locked(item)){ + oval_collection_add(item->messages, message); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_result_item_message_consumer diff -u -r a/src/OVAL/oval_resultSystem.c b/src/OVAL/oval_resultSystem.c --- a/src/OVAL/oval_resultSystem.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultSystem.c 2009-12-11 13:52:12 -0500 @@ -40,19 +40,21 @@ typedef struct oval_result_system { + struct oval_results_model *model; struct oval_string_map *definitions; struct oval_string_map *tests; struct oval_syschar_model *syschar_model; bool definitions_initialized; } oval_result_system_t; -struct oval_result_system *oval_result_system_new(struct oval_syschar_model *syschar_model) +struct oval_result_system *oval_result_system_new(struct oval_results_model *model, struct oval_syschar_model *syschar_model) { oval_result_system_t *sys = (oval_result_system_t *)malloc(sizeof(oval_result_system_t)); sys->definitions = oval_string_map_new(); sys->tests = oval_string_map_new(); sys->syschar_model = syschar_model; sys->definitions_initialized = false; + sys->model = model; return sys; } @@ -62,11 +64,11 @@ } bool oval_result_system_is_locked(struct oval_result_system *result_system) { - return false;//TODO + return oval_results_model_is_locked(result_system->model); } -typedef void (*_oval_result_system_clone_func)(void *, struct oval_result_system *); +typedef void (*_oval_result_system_clone_func)(struct oval_result_system *, void *); static void _oval_result_system_clone (struct oval_string_map *oldmap, struct oval_result_system *new_system, _oval_result_system_clone_func cloner) @@ -74,15 +76,15 @@ struct oval_string_iterator *keys = (struct oval_string_iterator *)oval_string_map_keys(oldmap); while(oval_string_iterator_has_more(keys)){ char *key = oval_string_iterator_next(keys); - void *olditem = oval_string_map_get_value(oldmap, key); - (*cloner)(olditem, new_system); + void *old_item = oval_string_map_get_value(oldmap, key); + (*cloner)(new_system, old_item); } oval_string_iterator_free(keys); } -struct oval_result_system *oval_result_system_clone(struct oval_result_system *old_system, struct oval_results_model *resmodel) +struct oval_result_system *oval_result_system_clone(struct oval_results_model *new_model, struct oval_result_system *old_system) { - struct oval_result_system *new_system = oval_result_system_new(oval_result_system_get_syschar_model(old_system)); + struct oval_result_system *new_system = oval_result_system_new(new_model, oval_result_system_get_syschar_model(old_system)); _oval_result_system_clone (old_system->definitions, new_system, @@ -243,21 +245,25 @@ void oval_result_system_add_definition (struct oval_result_system *sys, struct oval_result_definition *definition) { - if(definition){ - struct oval_definition *ovaldef = oval_result_definition_get_definition(definition); - char *id = oval_definition_get_id(ovaldef); - oval_string_map_put(sys->definitions, id, definition); - } + if(sys && !oval_result_system_is_locked(sys)){ + if(definition){ + struct oval_definition *ovaldef = oval_result_definition_get_definition(definition); + char *id = oval_definition_get_id(ovaldef); + oval_string_map_put(sys->definitions, id, definition); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_system_add_test (struct oval_result_system *sys, struct oval_result_test *test) { - if(test){ - struct oval_test *ovaldef = oval_result_test_get_test(test); - char *id = oval_test_get_id(ovaldef); - oval_string_map_put(sys->tests, id, test); - } + if(sys && !oval_result_system_is_locked(sys)){ + if(test){ + struct oval_test *ovaldef = oval_result_test_get_test(test); + char *id = oval_test_get_id(ovaldef); + oval_string_map_put(sys->tests, id, test); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_result_system_test_consume @@ -286,7 +292,7 @@ (xmlTextReaderPtr reader, struct oval_parser_context *context, struct oval_result_system *sys) { - return oval_result_definition_parse + int returns = oval_result_definition_parse (reader, context, sys, (oscap_consumer_func)_oval_result_system_definition_consume, sys); } @@ -332,8 +338,7 @@ ,void *client) { int return_code = 1; - struct oval_result_system *sys = oval_result_system_new - (syschar_model); + struct oval_result_system *sys = oval_result_system_new(context->results_model, syschar_model); return_code = oval_parser_parse_tag (reader, context, (oval_xml_tag_parser)_oval_result_system_parse, sys); diff -u -r a/src/OVAL/oval_resultTest.c b/src/OVAL/oval_resultTest.c --- a/src/OVAL/oval_resultTest.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_resultTest.c 2009-12-11 13:53:04 -0500 @@ -185,11 +185,11 @@ } bool oval_result_test_is_locked(struct oval_result_test *result_test) { - return false;//TODO + return oval_result_system_is_locked(result_test->system); } struct oval_result_test *oval_result_test_clone - (struct oval_result_test *old_test, struct oval_result_system *new_system) + (struct oval_result_system *new_system, struct oval_result_test *old_test) { struct oval_test *oval_test = oval_result_test_get_test(old_test); char *testid = oval_test_get_id(oval_test); @@ -197,7 +197,7 @@ struct oval_result_item_iterator *old_items = oval_result_test_get_items(old_test); while(oval_result_item_iterator_has_more(old_items)){ struct oval_result_item *old_item = oval_result_item_iterator_next(old_items); - struct oval_result_item *new_item = oval_result_item_clone(old_item, new_system); + struct oval_result_item *new_item = oval_result_item_clone(new_system, old_item); oval_result_test_add_item(new_test, new_item); } oval_result_item_iterator_free(old_items); @@ -809,31 +809,41 @@ void oval_result_test_set_result(struct oval_result_test *test, oval_result_t result) { - test->result = result; + if(test && !oval_result_test_is_locked(test)){ + test->result = result; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_test_set_instance(struct oval_result_test *test, int instance) { - test->instance = instance; + if(test && !oval_result_test_is_locked(test)){ + test->instance = instance; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_test_set_message (struct oval_result_test *test, struct oval_message *message) { - if(test->message)oval_message_free(test->message); - test->message = message; + if(test && !oval_result_test_is_locked(test)){ + if(test->message)oval_message_free(test->message); + test->message = message; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_test_add_item (struct oval_result_test *test, struct oval_result_item *item) { - oval_collection_add(test->items, item); + if(test && !oval_result_test_is_locked(test)){ + oval_collection_add(test->items, item); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_result_test_add_binding (struct oval_result_test *test, struct oval_variable_binding *binding) { - oval_collection_add(test->bindings, binding); + if(test && !oval_result_test_is_locked(test)){ + oval_collection_add(test->bindings, binding); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //void(*oscap_consumer_func)(void*, void*); diff -u -r a/src/OVAL/oval_results_parser.c b/src/OVAL/oval_results_parser.c --- a/src/OVAL/oval_results_parser.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_results_parser.c 2009-12-11 11:07:39 -0500 @@ -38,7 +38,7 @@ #define NAMESPACE_OVALRES "http://oval.mitre.org/XMLSchema/oval-results-5" #define NAMESPACE_OVALDEF "http://oval.mitre.org/XMLSchema/oval-definitions-5" -#define DEBUG_OVALRES_PARSER 1 +#define DEBUG_OVALRES_PARSER 0 static void _oval_results_parser_consume_system @@ -92,7 +92,7 @@ return_code = oval_parser_skip_tag(reader,context); }else if (is_ovalres && (strcmp(tagname, "directives") == 0)) { - *directives = oval_result_directives_new(); + *directives = oval_result_directives_new(context->results_model); return_code = oval_result_directives_parse_tag(reader, context, *directives); }else if (is_ovaldef && (strcmp(tagname, "oval_definitions") == 0)) { if(DEBUG_OVALRES_PARSER)oval_parser_log_debug(context,"Calling oval_parser_parse_node"); diff -u -r a/src/OVAL/oval_set.c b/src/OVAL/oval_set.c --- a/src/OVAL/oval_set.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_set.c 2009-12-11 13:36:05 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_setobject { + struct oval_definition_model *model; oval_setobject_type_t type; oval_setobject_operation_t operation; void *extension; @@ -114,12 +115,13 @@ return filters; } -struct oval_setobject *oval_setobject_new() +struct oval_setobject *oval_setobject_new(struct oval_definition_model* model) { oval_set_t *set = (oval_set_t *) malloc(sizeof(oval_set_t)); set->operation = OVAL_SET_OPERATION_UNKNOWN; set->type = OVAL_SET_UNKNOWN; set->extension = NULL; + set->model = model; return set; } @@ -129,13 +131,13 @@ } bool oval_setobject_is_locked(struct oval_setobject *setobject) { - return false;//TODO + return oval_definition_model_is_locked(setobject->model); } struct oval_setobject *oval_setobject_clone - (struct oval_setobject *old_setobject, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_setobject *old_setobject) { - struct oval_setobject *new_setobject = oval_setobject_new(); + struct oval_setobject *new_setobject = oval_setobject_new(new_model); oval_setobject_type_t type = oval_setobject_get_type(old_setobject); oval_setobject_set_type(new_setobject, type); oval_setobject_operation_t operation = oval_setobject_get_operation(old_setobject); @@ -146,13 +148,13 @@ struct oval_state_iterator *filters = oval_setobject_get_filters(old_setobject); while(oval_state_iterator_has_more(filters)){ struct oval_state *filter = oval_state_iterator_next(filters); - oval_setobject_add_filter(new_setobject, oval_state_clone(filter, model)); + oval_setobject_add_filter(new_setobject, oval_state_clone(new_model, filter)); } oval_state_iterator_free(filters); struct oval_object_iterator *objects = oval_setobject_get_objects(old_setobject); while(oval_object_iterator_has_more(objects)){ struct oval_object *object = oval_object_iterator_next(objects); - oval_setobject_add_object(new_setobject, oval_object_clone(object, model)); + oval_setobject_add_object(new_setobject, oval_object_clone(new_model, object)); } oval_object_iterator_free(objects); @@ -200,54 +202,64 @@ void oval_setobject_set_type(struct oval_setobject *set, oval_setobject_type_t type) { - set->type = type; - switch (type) { - case OVAL_SET_AGGREGATE:{ - oval_set_AGGREGATE_t *aggregate = - (oval_set_AGGREGATE_t *) (set->extension = - malloc(sizeof - (oval_set_AGGREGATE_t))); - aggregate->subsets = oval_collection_new(); - } - break; - case OVAL_SET_COLLECTIVE:{ - oval_set_COLLECTIVE_t *collective = - (oval_set_COLLECTIVE_t *) (set->extension = - malloc(sizeof - (oval_set_COLLECTIVE_t))); - collective->filters = oval_collection_new(); - collective->objects = oval_collection_new(); + if(set && !oval_setobject_is_locked(set)){ + set->type = type; + switch (type) { + case OVAL_SET_AGGREGATE:{ + oval_set_AGGREGATE_t *aggregate = + (oval_set_AGGREGATE_t *) (set->extension = + malloc(sizeof + (oval_set_AGGREGATE_t))); + aggregate->subsets = oval_collection_new(); + } + break; + case OVAL_SET_COLLECTIVE:{ + oval_set_COLLECTIVE_t *collective = + (oval_set_COLLECTIVE_t *) (set->extension = + malloc(sizeof + (oval_set_COLLECTIVE_t))); + collective->filters = oval_collection_new(); + collective->objects = oval_collection_new(); + } + break; + case OVAL_SET_UNKNOWN: break; } - break; - case OVAL_SET_UNKNOWN: break; - } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_setobject_set_operation(struct oval_setobject *set, oval_setobject_operation_t operation) { - set->operation = operation; + if(set && !oval_setobject_is_locked(set)){ + set->operation = operation; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_setobject_add_subset(struct oval_setobject *set, struct oval_setobject *subset) { - oval_set_AGGREGATE_t *aggregate = - (oval_set_AGGREGATE_t *) set->extension; - oval_collection_add(aggregate->subsets, (void *)subset); + if(set && !oval_setobject_is_locked(set)){ + oval_set_AGGREGATE_t *aggregate = + (oval_set_AGGREGATE_t *) set->extension; + oval_collection_add(aggregate->subsets, (void *)subset); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_setobject_add_object(struct oval_setobject *set, struct oval_object *object) { - oval_set_COLLECTIVE_t *collective = - (oval_set_COLLECTIVE_t *) set->extension; - oval_collection_add(collective->objects, (void *)object); + if(set && !oval_setobject_is_locked(set)){ + oval_set_COLLECTIVE_t *collective = + (oval_set_COLLECTIVE_t *) set->extension; + oval_collection_add(collective->objects, (void *)object); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_setobject_add_filter(struct oval_setobject *set, struct oval_state *filter) { - oval_set_COLLECTIVE_t *collective = - (oval_set_COLLECTIVE_t *) set->extension; - oval_collection_add(collective->filters, (void *)filter); + if(set && !oval_setobject_is_locked(set)){ + oval_set_COLLECTIVE_t *collective = + (oval_set_COLLECTIVE_t *) set->extension; + oval_collection_add(collective->filters, (void *)filter); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } //typedef int (*oval_xml_tag_parser)(xmlTextReaderPtr, struct oval_parser_context*, void*); @@ -329,7 +341,7 @@ { xmlChar *tagname = xmlTextReaderName(reader); xmlChar *namespace = xmlTextReaderNamespaceUri(reader); - struct oval_setobject *set = oval_setobject_new(); + struct oval_setobject *set = oval_setobject_new(context->definition_model); oval_setobject_operation_t operation = oval_set_operation_parse(reader, "set_operator", diff -u -r a/src/OVAL/oval_sexp.c b/src/OVAL/oval_sexp.c --- a/src/OVAL/oval_sexp.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sexp.c 2009-12-11 16:21:40 -0500 @@ -624,13 +624,13 @@ return sysdata; } -struct oval_syschar *oval_sexp2sysch (const SEXP_t *s_exp, struct oval_object *object) +struct oval_syschar *oval_sexp2sysch (const SEXP_t *s_exp, struct oval_syschar_model *model, struct oval_object *object) { struct oval_syschar *sysch; _A(s_exp != NULL); - sysch = oval_syschar_new(object); + sysch = oval_syschar_new(model, object); if (oval_sysch_apply_sexp (sysch, s_exp, object) != 0) { oval_syschar_free (sysch); diff -u -r a/src/OVAL/oval_sexp.h b/src/OVAL/oval_sexp.h --- a/src/OVAL/oval_sexp.h 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sexp.h 2009-12-11 16:25:11 -0500 @@ -18,7 +18,7 @@ /* * S-exp -> OVAL */ -struct oval_syschar *oval_sexp2sysch (const SEXP_t *s_exp, struct oval_object *object); +struct oval_syschar *oval_sexp2sysch (const SEXP_t *s_exp, struct oval_syschar_model *model, struct oval_object *object); int oval_sysch_apply_sexp (struct oval_syschar *sysch, const SEXP_t *s_list, struct oval_object *object); OSCAP_HIDDEN_END; diff -u -r a/src/OVAL/oval_state.c b/src/OVAL/oval_state.c --- a/src/OVAL/oval_state.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_state.c 2009-12-11 14:07:12 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_state { + struct oval_definition_model *model; oval_subtype_t subtype; char *comment; char *id; @@ -110,7 +111,7 @@ return state->version; } -struct oval_state *oval_state_new(char* id) +struct oval_state *oval_state_new(struct oval_definition_model* model, char* id) { oval_state_t *state = (oval_state_t *) malloc(sizeof(oval_state_t)); state->deprecated = 0; @@ -120,6 +121,7 @@ state->id = strdup(id); state->notes = oval_collection_new(); state->contents = oval_collection_new(); + state->model = model; return state; } @@ -129,15 +131,15 @@ } bool oval_state_is_locked(struct oval_state *state) { - return false;//TODO + return oval_definition_model_is_locked(state->model); } struct oval_state *oval_state_clone - (struct oval_state *old_state, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_state *old_state) { - oval_state_t *new_state = oval_definition_model_get_state(model, old_state->id); + oval_state_t *new_state = oval_definition_model_get_state(new_model, old_state->id); if(new_state==NULL){ - new_state = oval_state_new(old_state->id); + new_state = oval_state_new(new_model, old_state->id); oval_state_set_deprecated(new_state, old_state->deprecated); oval_state_set_version (new_state, old_state->version); oval_state_set_subtype (new_state, old_state->subtype); @@ -152,11 +154,11 @@ struct oval_state_content_iterator *contents = oval_state_get_contents(old_state); while(oval_state_content_iterator_has_more(contents)){ struct oval_state_content *content = oval_state_content_iterator_next(contents); - oval_state_add_content(new_state, oval_state_content_clone(content, model)); + oval_state_add_content(new_state, oval_state_content_clone(new_model, content)); } oval_state_content_iterator_free(contents); - oval_definition_model_add_state(model, new_state); + oval_definition_model_add_state(new_model, new_state); } return new_state; } @@ -179,34 +181,46 @@ void oval_state_set_subtype(struct oval_state *state, oval_subtype_t subtype) { - state->subtype = subtype; + if(state && !oval_state_is_locked(state)){ + state->subtype = subtype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_add_note(struct oval_state *state, char *notes) { - oval_collection_add(state->notes, (void *)strdup(notes)); + if(state && !oval_state_is_locked(state)){ + oval_collection_add(state->notes, (void *)strdup(notes)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_set_comment(struct oval_state *state, char *comm) { - if(state->comment!=NULL)free(state->comment); - state->comment = comm==NULL?NULL:strdup(comm); + if(state && !oval_state_is_locked(state)){ + if(state->comment!=NULL)free(state->comment); + state->comment = comm==NULL?NULL:strdup(comm); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_set_deprecated(struct oval_state *state, bool deprecated) { - state->deprecated = deprecated; + if(state && !oval_state_is_locked(state)){ + state->deprecated = deprecated; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_set_version(struct oval_state *state, int version) { - state->version = version; + if(state && !oval_state_is_locked(state)){ + state->version = version; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_add_content (struct oval_state *state, struct oval_state_content *content) { - oval_collection_add(state->contents, content); + if(state && !oval_state_is_locked(state)){ + oval_collection_add(state->contents, content); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_note_consumer(char *text, void *state) { diff -u -r a/src/OVAL/oval_stateContent.c b/src/OVAL/oval_stateContent.c --- a/src/OVAL/oval_stateContent.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_stateContent.c 2009-12-11 14:07:12 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_state_content { + struct oval_definition_model *model; struct oval_entity *entity; oval_check_t ent_check; oval_check_t var_check; @@ -82,13 +83,14 @@ return content->ent_check; } -struct oval_state_content *oval_state_content_new() +struct oval_state_content *oval_state_content_new(struct oval_definition_model* model) { oval_state_content_t *content = (oval_state_content_t *) malloc(sizeof(oval_state_content_t)); content->entity = NULL; content->ent_check = OVAL_CHECK_UNKNOWN; content->var_check = OVAL_CHECK_UNKNOWN; + content->model = model; return content; } @@ -98,17 +100,17 @@ } bool oval_state_content_is_locked(struct oval_state_content *state_content) { - return false;//TODO + return oval_definition_model_is_locked(state_content->model); } struct oval_state_content *oval_state_content_clone - (struct oval_state_content *old_content, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_state_content *old_content) { - struct oval_state_content *new_content = oval_state_content_new(); + struct oval_state_content *new_content = oval_state_content_new(new_model); oval_check_t echeck = oval_state_content_get_ent_check(old_content); oval_state_content_set_entcheck(new_content, echeck); struct oval_entity *entity = oval_state_content_get_entity(old_content); - oval_state_content_set_entity(new_content, oval_entity_clone(entity, model)); + oval_state_content_set_entity(new_content, oval_entity_clone(new_model, entity)); oval_check_t vcheck = oval_state_content_get_var_check(old_content); oval_state_content_set_varcheck(new_content, vcheck); return new_content; @@ -122,18 +124,24 @@ void oval_state_content_set_entity(struct oval_state_content *content, struct oval_entity *entity) { - if(content->entity)oval_entity_free(content->entity); - content->entity = entity; + if(content && !oval_state_content_is_locked(content)){ + if(content->entity)oval_entity_free(content->entity); + content->entity = entity; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_content_set_varcheck(struct oval_state_content *content, oval_check_t check) { - content->var_check = check; + if(content && !oval_state_content_is_locked(content)){ + content->var_check = check; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_state_content_set_entcheck(struct oval_state_content *content, oval_check_t check) { - content->ent_check = check; + if(content && !oval_state_content_is_locked(content)){ + content->ent_check = check; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_state_content_entity_consumer @@ -146,7 +154,7 @@ void *user) { - struct oval_state_content *content = oval_state_content_new(); + struct oval_state_content *content = oval_state_content_new(context->definition_model); int retcode = oval_entity_parse_tag (reader, context, (oscap_consumer_func)_oval_state_content_entity_consumer, content); diff -u -r a/src/OVAL/oval_sysData.c b/src/OVAL/oval_sysData.c --- a/src/OVAL/oval_sysData.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sysData.c 2009-12-11 13:37:45 -0500 @@ -38,6 +38,7 @@ typedef struct oval_sysdata { //oval_family_enum family; + struct oval_syschar_model *model; oval_subtype_t subtype; oval_message_level_t message_level; char* id; @@ -46,7 +47,7 @@ oval_syschar_status_t status; } oval_sysdata_t; -struct oval_sysdata *oval_sysdata_new(char *id) +struct oval_sysdata *oval_sysdata_new(struct oval_syschar_model* model, char *id) { oval_sysdata_t *sysdata = (oval_sysdata_t*)malloc(sizeof(oval_sysdata_t)); sysdata->id = strdup(id); @@ -55,6 +56,7 @@ sysdata->status = SYSCHAR_STATUS_UNKNOWN; sysdata->message = NULL; sysdata->items = oval_collection_new(); + sysdata->model = model; return sysdata; } @@ -64,12 +66,12 @@ } bool oval_sysdata_is_locked(struct oval_sysdata *sysdata) { - return false;//TODO + return oval_syschar_model_is_locked(sysdata->model); } -struct oval_sysdata *oval_sysdata_clone(struct oval_sysdata *old_data, struct oval_syschar_model *model) +struct oval_sysdata *oval_sysdata_clone(struct oval_syschar_model *new_model, struct oval_sysdata *old_data) { - struct oval_sysdata *new_data = oval_sysdata_new(oval_sysdata_get_id(old_data)); + struct oval_sysdata *new_data = oval_sysdata_new(new_model, oval_sysdata_get_id(old_data)); char *old_message = oval_sysdata_get_message(old_data); if(old_message){ oval_sysdata_set_message(new_data, strdup(old_message)); @@ -77,17 +79,17 @@ } oval_sysdata_set_status(new_data, oval_sysdata_get_status(old_data)); - oval_sysdata_set_subtype(old_data, oval_sysdata_get_subtype(old_data)); + oval_sysdata_set_subtype(new_data, oval_sysdata_get_subtype(old_data)); struct oval_sysitem_iterator *old_items = oval_sysdata_get_items(old_data); while(oval_sysitem_iterator_has_more(old_items)){ struct oval_sysitem *old_item = oval_sysitem_iterator_next(old_items); - struct oval_sysitem *new_item = oval_sysitem_clone(old_item); + struct oval_sysitem *new_item = oval_sysitem_clone(new_model, old_item); oval_sysdata_add_item(new_data, new_item); } oval_sysitem_iterator_free(old_items); - oval_syschar_model_add_sysdata(model, new_data); + oval_syschar_model_add_sysdata(new_model, new_data); return new_data; } @@ -131,7 +133,9 @@ void oval_sysdata_set_subtype(struct oval_sysdata *sysdata, oval_subtype_t subtype) { - sysdata->subtype = subtype; + if(sysdata && !oval_sysdata_is_locked(sysdata)){ + sysdata->subtype = subtype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysdata_get_id(struct oval_sysdata *data) @@ -145,8 +149,10 @@ } void oval_sysdata_set_message(struct oval_sysdata *data, char *message) { - if(data->message!=NULL)free(data->message); - data->message = message==NULL?NULL:strdup(message); + if(data && !oval_sysdata_is_locked(data)){ + if(data->message!=NULL)free(data->message); + data->message = message==NULL?NULL:strdup(message); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } oval_message_level_t oval_sysdata_get_message_level(struct oval_sysdata *data) { @@ -154,7 +160,9 @@ } void oval_sysdata_set_message_level(struct oval_sysdata *data, oval_message_level_t level) { - data->message_level = level; + if(data && !oval_sysdata_is_locked(data)){ + data->message_level = level; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_sysitem_iterator *oval_sysdata_get_items(struct oval_sysdata *data) { @@ -162,7 +170,9 @@ } void oval_sysdata_add_item(struct oval_sysdata *data, struct oval_sysitem* item) { - oval_collection_add(data->items, item); + if(data && !oval_sysdata_is_locked(data)){ + oval_collection_add(data->items, item); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } oval_syschar_status_t oval_sysdata_get_status(struct oval_sysdata *data) { @@ -170,7 +180,9 @@ } void oval_sysdata_set_status(struct oval_sysdata *data, oval_syschar_status_t status) { - data->status = status; + if(data && !oval_sysdata_is_locked(data)){ + data->status = status; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_sysdata_parse_subtag_consume(char* message, void* sysdata) { @@ -314,7 +326,8 @@ const char* subtype_text = oval_subtype_get_text(subtype); char tagname[strlen(subtype_text)+6];*tagname = '\0'; sprintf(tagname, "%s_item", subtype_text); - xmlNode *tag_sysdata = xmlNewChild + + xmlNode *tag_sysdata = xmlNewChild (tag_parent, NULL, BAD_CAST tagname, NULL); xmlNs *ns_family = xmlNewNs(tag_sysdata, BAD_CAST family_namespace, NULL); xmlSetNs(tag_sysdata, ns_family); @@ -345,7 +358,8 @@ oval_sysitem_iterator_free(items); } }else{ - fprintf(stderr,"WARNING: Skipping XML generation of oval_sysdata with subtype OVAL_SUBTYPE_UNKNOWN"); + fprintf(stderr,"WARNING: Skipping XML generation of oval_sysdata with subtype OVAL_SUBTYPE_UNKNOWN\n" + " %s(%d)\n", __FILE__, __LINE__); } } } diff -u -r a/src/OVAL/oval_sysInfo.c b/src/OVAL/oval_sysInfo.c --- a/src/OVAL/oval_sysInfo.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sysInfo.c 2009-12-11 13:38:00 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_sysinfo { + struct oval_syschar_model *model; char *osName; char *osVersion; char *osArchitecture; @@ -42,7 +43,7 @@ struct oval_collection *interfaces; } oval_sysinfo_t; -struct oval_sysinfo *oval_sysinfo_new() +struct oval_sysinfo *oval_sysinfo_new(struct oval_syschar_model* model) { oval_sysinfo_t *sysinfo = (oval_sysinfo_t*)malloc(sizeof(oval_sysinfo_t)); sysinfo->osArchitecture = NULL; @@ -50,6 +51,7 @@ sysinfo->osVersion = NULL; sysinfo->primaryHostName = NULL; sysinfo->interfaces = oval_collection_new(); + sysinfo->model = model; return sysinfo; } @@ -59,12 +61,12 @@ } bool oval_sysinfo_is_locked(struct oval_sysinfo *sysinfo) { - return false;//TODO + return oval_syschar_model_is_locked(sysinfo->model); } -struct oval_sysinfo *oval_sysinfo_clone(struct oval_sysinfo *old_sysinfo) +struct oval_sysinfo *oval_sysinfo_clone(struct oval_syschar_model *new_model, struct oval_sysinfo *old_sysinfo) { - struct oval_sysinfo *new_sysinfo = oval_sysinfo_new(); + struct oval_sysinfo *new_sysinfo = oval_sysinfo_new(new_model); struct oval_sysint_iterator *interfaces = oval_sysinfo_get_interfaces(old_sysinfo); while(oval_sysint_iterator_has_more(interfaces)){ struct oval_sysint *interface = oval_sysint_iterator_next(interfaces); @@ -135,8 +137,10 @@ void oval_sysinfo_set_os_name(struct oval_sysinfo *sysinfo, char *osName) { - if(sysinfo->osName!=NULL)free(sysinfo->osName); - sysinfo->osName = osName==NULL?NULL:strdup(osName); + if(sysinfo && !oval_sysinfo_is_locked(sysinfo)){ + if(sysinfo->osName!=NULL)free(sysinfo->osName); + sysinfo->osName = osName==NULL?NULL:strdup(osName); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysinfo_get_os_version(struct oval_sysinfo *sysinfo) @@ -146,8 +150,10 @@ void oval_sysinfo_set_os_version(struct oval_sysinfo *sysinfo, char *osVersion) { - if(sysinfo->osVersion!=NULL)free(sysinfo->osVersion); - sysinfo->osVersion = osVersion==NULL?NULL:strdup(osVersion); + if(sysinfo && !oval_sysinfo_is_locked(sysinfo)){ + if(sysinfo->osVersion!=NULL)free(sysinfo->osVersion); + sysinfo->osVersion = osVersion==NULL?NULL:strdup(osVersion); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysinfo_get_os_architecture(struct oval_sysinfo *sysinfo) @@ -157,8 +163,10 @@ void oval_sysinfo_set_os_architecture(struct oval_sysinfo *sysinfo, char *osArchitecture) { - if(sysinfo->osArchitecture!=NULL)free(sysinfo->osArchitecture); - sysinfo->osArchitecture = osArchitecture==NULL?NULL:strdup(osArchitecture); + if(sysinfo && !oval_sysinfo_is_locked(sysinfo)){ + if(sysinfo->osArchitecture!=NULL)free(sysinfo->osArchitecture); + sysinfo->osArchitecture = osArchitecture==NULL?NULL:strdup(osArchitecture); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysinfo_get_primary_host_name(struct oval_sysinfo *sysinfo) @@ -168,8 +176,10 @@ void oval_sysinfo_set_primary_host_name(struct oval_sysinfo *sysinfo, char *primaryHostName) { - if(sysinfo->primaryHostName!=NULL)free(sysinfo->primaryHostName); - sysinfo->primaryHostName = primaryHostName==NULL?NULL:strdup(primaryHostName); + if(sysinfo && !oval_sysinfo_is_locked(sysinfo)){ + if(sysinfo->primaryHostName!=NULL)free(sysinfo->primaryHostName); + sysinfo->primaryHostName = primaryHostName==NULL?NULL:strdup(primaryHostName); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_sysint_iterator *oval_sysinfo_get_interfaces(struct oval_sysinfo @@ -181,7 +191,9 @@ void oval_sysinfo_add_interface(struct oval_sysinfo *sysinfo, struct oval_sysint *interface) { - oval_collection_add(sysinfo->interfaces, oval_sysint_clone(interface)); + if(sysinfo && !oval_sysinfo_is_locked(sysinfo)){ + oval_collection_add(sysinfo->interfaces, oval_sysint_clone(sysinfo->model, interface)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_sysinfo_parse_tag_consume_os_name(char* text, void* sysinfo) @@ -245,7 +257,7 @@ int oval_sysinfo_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context) { - oval_sysinfo_t *sysinfo = oval_sysinfo_new(); + oval_sysinfo_t *sysinfo = oval_sysinfo_new(context->syschar_model); char *tagname = (char*) xmlTextReaderName(reader); char *namespace = (char*) xmlTextReaderNamespaceUri(reader); int is_ovalsys = strcmp(namespace,NAMESPACE_OVALSYS)==0; diff -u -r a/src/OVAL/oval_sysInterface.c b/src/OVAL/oval_sysInterface.c --- a/src/OVAL/oval_sysInterface.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sysInterface.c 2009-12-11 13:38:22 -0500 @@ -34,6 +34,7 @@ #include "oval_collection_impl.h" typedef struct oval_sysint { + struct oval_syschar_model *model; char *name; char *ipAddress; char *macAddress; @@ -63,8 +64,10 @@ void oval_sysint_set_name(struct oval_sysint *sysint, char *name) { - if(sysint->name!=NULL)free(sysint->name); - sysint->name = name==NULL?NULL:strdup(name); + if(sysint && !oval_sysint_is_locked(sysint)){ + if(sysint->name!=NULL)free(sysint->name); + sysint->name = name==NULL?NULL:strdup(name); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysint_get_ip_address(struct oval_sysint *sysint) @@ -74,8 +77,10 @@ void oval_sysint_set_ip_address(struct oval_sysint *sysint, char *ip_address) { - if(sysint->ipAddress!=NULL)free(sysint->ipAddress); - sysint->ipAddress = (ip_address==NULL)?NULL:strdup(ip_address); + if(sysint && !oval_sysint_is_locked(sysint)){ + if(sysint->ipAddress!=NULL)free(sysint->ipAddress); + sysint->ipAddress = (ip_address==NULL)?NULL:strdup(ip_address); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } char *oval_sysint_get_mac_address(struct oval_sysint *sysint) @@ -85,16 +90,19 @@ void oval_sysint_set_mac_address(struct oval_sysint *sysint, char *mac_address) { - if(sysint->macAddress!=NULL)free(sysint->macAddress); - sysint->macAddress = (mac_address==NULL)?NULL:strdup(mac_address); + if(sysint && !oval_sysint_is_locked(sysint)){ + if(sysint->macAddress!=NULL)free(sysint->macAddress); + sysint->macAddress = (mac_address==NULL)?NULL:strdup(mac_address); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } -struct oval_sysint *oval_sysint_new() +struct oval_sysint *oval_sysint_new(struct oval_syschar_model* model) { oval_sysint_t *sysint = (oval_sysint_t*)malloc(sizeof(oval_sysint_t)); sysint->ipAddress = NULL; sysint->macAddress = NULL; sysint->name = NULL; + sysint->model = model; return sysint; } @@ -104,12 +112,12 @@ } bool oval_sysint_is_locked(struct oval_sysint *sysint) { - return false;//TODO + return oval_syschar_model_is_locked(sysint->model); } -struct oval_sysint *oval_sysint_clone(struct oval_sysint *old_sysint) +struct oval_sysint *oval_sysint_clone(struct oval_syschar_model *new_model, struct oval_sysint *old_sysint) { - struct oval_sysint *new_sysint = oval_sysint_new(); + struct oval_sysint *new_sysint = oval_sysint_new(new_model); char *ip_address = oval_sysint_get_ip_address(old_sysint); if(ip_address){ oval_sysint_set_ip_address(new_sysint, ip_address); @@ -179,7 +187,7 @@ int oval_sysint_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context, oval_sysint_consumer consumer , void *user){ - struct oval_sysint *sysint = oval_sysint_new(); + struct oval_sysint *sysint = oval_sysint_new(context->syschar_model); char *tagname = (char*) xmlTextReaderName(reader); char *namespace = (char*) xmlTextReaderNamespaceUri(reader); int is_ovalsys = strcmp(namespace,NAMESPACE_OVALSYS)==0; diff -u -r a/src/OVAL/oval_sysItem.c b/src/OVAL/oval_sysItem.c --- a/src/OVAL/oval_sysItem.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_sysItem.c 2009-12-11 13:38:38 -0500 @@ -37,6 +37,7 @@ static int DEBUG_OVAL_SYSITEM = 0; typedef struct oval_sysitem { + struct oval_syschar_model *model; char* name; char* value; int mask; @@ -44,7 +45,7 @@ oval_syschar_status_t status; } oval_sysitem_t; -struct oval_sysitem *oval_sysitem_new() +struct oval_sysitem *oval_sysitem_new(struct oval_syschar_model* model) { oval_sysitem_t *sysitem = (oval_sysitem_t*)malloc(sizeof(oval_sysitem_t)); sysitem->name = NULL; @@ -52,6 +53,7 @@ sysitem->status = SYSCHAR_STATUS_UNKNOWN; sysitem->datatype = OVAL_DATATYPE_UNKNOWN; sysitem->mask = 0; + sysitem->model = model; return sysitem; } @@ -61,12 +63,12 @@ } bool oval_sysitem_is_locked(struct oval_sysitem *sysitem) { - return false;//TODO + return oval_syschar_model_is_locked(sysitem->model); } -struct oval_sysitem *oval_sysitem_clone(struct oval_sysitem *old_item) +struct oval_sysitem *oval_sysitem_clone(struct oval_syschar_model *new_model, struct oval_sysitem *old_item) { - struct oval_sysitem *new_item = oval_sysitem_new(); + struct oval_sysitem *new_item = oval_sysitem_new(new_model); char *old_value = oval_sysitem_get_value(old_item); @@ -127,25 +129,35 @@ void oval_sysitem_set_name(struct oval_sysitem *sysitem, char *name) { - if(sysitem->name!=NULL)free(sysitem->name); - sysitem->name = name==NULL?NULL:strdup(name); + if(sysitem && !oval_sysitem_is_locked(sysitem)){ + if(sysitem->name!=NULL)free(sysitem->name); + sysitem->name = name==NULL?NULL:strdup(name); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_sysitem_set_status(struct oval_sysitem *sysitem, oval_syschar_status_t status) { - sysitem->status = status; + if(sysitem && !oval_sysitem_is_locked(sysitem)){ + sysitem->status = status; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_sysitem_set_datatype(struct oval_sysitem *sysitem, oval_datatype_t datatype) { - sysitem->datatype = datatype; + if(sysitem && !oval_sysitem_is_locked(sysitem)){ + sysitem->datatype = datatype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_sysitem_set_mask(struct oval_sysitem *sysitem, int mask) { - sysitem->mask = mask; + if(sysitem && !oval_sysitem_is_locked(sysitem)){ + sysitem->mask = mask; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_sysitem_set_value(struct oval_sysitem *sysitem, char *value) { - if(sysitem->value!=NULL)free(sysitem->value); - sysitem->value = value==NULL?NULL:strdup(value); + if(sysitem && !oval_sysitem_is_locked(sysitem)){ + if(sysitem->value!=NULL)free(sysitem->value); + sysitem->value = value==NULL?NULL:strdup(value); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void oval_sysitem_value_consumer_(char* value, void* sysitem){ @@ -165,7 +177,7 @@ int return_code = 1; char *tagname = (char*) xmlTextReaderName(reader); if(strcmp("#text", tagname)){ - struct oval_sysitem *sysitem = oval_sysitem_new(); + struct oval_sysitem *sysitem = oval_sysitem_new(context->syschar_model); {//sysitem->name oval_sysitem_set_name(sysitem, tagname); } diff -u -r a/src/OVAL/oval_syschar.c b/src/OVAL/oval_syschar.c --- a/src/OVAL/oval_syschar.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_syschar.c 2009-12-11 13:37:26 -0500 @@ -38,6 +38,7 @@ static int OVAL_SYSCHAR_DEBUG = 0; typedef struct oval_syschar { + struct oval_syschar_model *model; oval_syschar_collection_flag_t flag; struct oval_collection *messages; struct oval_object *object; @@ -73,12 +74,16 @@ void oval_syschar_set_flag (struct oval_syschar *syschar, oval_syschar_collection_flag_t flag) { - syschar->flag = flag; + if(syschar && !oval_syschar_is_locked(syschar)){ + syschar->flag = flag; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_syschar_set_object(struct oval_syschar *syschar, struct oval_object *object) { - syschar->object = object; + if(syschar && !oval_syschar_is_locked(syschar)){ + syschar->object = object; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } @@ -90,7 +95,9 @@ void oval_syschar_add_message(struct oval_syschar *syschar, struct oval_message *message) { - oval_collection_add(syschar->messages, message); + if(syschar && !oval_syschar_is_locked(syschar)){ + oval_collection_add(syschar->messages, message); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } struct oval_object *oval_syschar_get_object(struct oval_syschar *syschar) @@ -115,22 +122,20 @@ void oval_syschar_add_sysdata (struct oval_syschar *syschar, struct oval_sysdata *sysdata) { - oval_collection_add(syschar->sysdata, sysdata); -} - -static void add_oval_syschar_message - (struct oval_syschar *syschar, struct oval_message *message) -{ - oval_collection_add(syschar->messages, message); + if(syschar && !oval_syschar_is_locked(syschar)){ + oval_collection_add(syschar->sysdata, sysdata); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_syschar_add_variable_binding (struct oval_syschar *syschar, struct oval_variable_binding *binding) { - oval_collection_add(syschar->variable_bindings, binding); + if(syschar && !oval_syschar_is_locked(syschar)){ + oval_collection_add(syschar->variable_bindings, binding); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } -struct oval_syschar *oval_syschar_new(struct oval_object *object) +struct oval_syschar *oval_syschar_new(struct oval_syschar_model* model, struct oval_object *object) { oval_syschar_t *syschar = (oval_syschar_t*)malloc(sizeof(oval_syschar_t)); syschar->flag = SYSCHAR_FLAG_UNKNOWN; @@ -138,6 +143,7 @@ syschar->messages = oval_collection_new(); syschar->sysdata = oval_collection_new(); syschar->variable_bindings = oval_collection_new(); + syschar->model = model; return syschar; } @@ -147,19 +153,19 @@ } bool oval_syschar_is_locked(struct oval_syschar *syschar) { - return false;//TODO + return oval_syschar_model_is_locked(syschar->model); } -struct oval_syschar *oval_syschar_clone(struct oval_syschar *old_syschar, struct oval_syschar_model *sys_model) +struct oval_syschar *oval_syschar_clone(struct oval_syschar_model *new_model, struct oval_syschar *old_syschar) { - struct oval_definition_model *def_model = oval_syschar_model_get_definition_model(sys_model); + struct oval_definition_model *def_model = oval_syschar_model_get_definition_model(new_model); struct oval_object *old_object = oval_syschar_get_object(old_syschar); struct oval_object *new_object = oval_definition_model_get_object(def_model, oval_object_get_id(old_object)); if(new_object==NULL){ - new_object = oval_object_clone(old_object, def_model); + new_object = oval_object_clone(def_model, old_object); } - struct oval_syschar *new_syschar = oval_syschar_new(new_object); + struct oval_syschar *new_syschar = oval_syschar_new(new_model, new_object); oval_syschar_collection_flag_t flag = oval_syschar_get_flag(old_syschar); oval_syschar_set_flag(new_syschar, flag); @@ -175,8 +181,8 @@ struct oval_sysdata_iterator *old_sysdatas = oval_syschar_get_sysdata(old_syschar); while(oval_sysdata_iterator_has_more(old_sysdatas)){ struct oval_sysdata *old_sysdata = oval_sysdata_iterator_next(old_sysdatas); - struct oval_sysdata *new_sysdata = oval_syschar_model_get_sysdata(sys_model, oval_sysdata_get_id(old_sysdata)); - if(new_sysdata==NULL)new_sysdata = oval_sysdata_clone(old_sysdata, sys_model); + struct oval_sysdata *new_sysdata = oval_syschar_model_get_sysdata(new_model, oval_sysdata_get_id(old_sysdata)); + if(new_sysdata==NULL)new_sysdata = oval_sysdata_clone(new_model, old_sysdata); oval_syschar_add_sysdata(new_syschar, new_sysdata); } oval_sysdata_iterator_free(old_sysdatas); @@ -189,7 +195,7 @@ } oval_variable_binding_iterator_free(old_bindings); - oval_syschar_model_add_syschar(sys_model, new_syschar); + oval_syschar_model_add_syschar(new_model, new_syschar); return new_syschar; } @@ -208,6 +214,12 @@ free(syschar); } +static void add_oval_syschar_message + (struct oval_syschar *syschar, struct oval_message *message) +{ + oval_collection_add(syschar->messages, message); +} + static void _oval_syschar_parse_subtag_consume_message(struct oval_message *message, void* syschar){ add_oval_syschar_message((struct oval_syschar *)syschar, message); } @@ -299,7 +311,6 @@ sprintf(message, "oval_syschar_parse_tag:: return code is not 1::(%d)",return_code); oval_parser_log_warn(context, message); } - return return_code; } diff -u -r a/src/OVAL/oval_test.c b/src/OVAL/oval_test.c --- a/src/OVAL/oval_test.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_test.c 2009-12-11 14:07:12 -0500 @@ -35,6 +35,7 @@ #include "oval_agent_api_impl.h" typedef struct oval_test { + struct oval_definition_model *model; oval_subtype_t subtype; struct oval_collection *notes; char *comment; @@ -120,7 +121,7 @@ return test->state; } -struct oval_test *oval_test_new(char *id) +struct oval_test *oval_test_new(struct oval_definition_model* model, char *id) { oval_test_t *test = (oval_test_t *) malloc(sizeof(oval_test_t)); test->deprecated = 0; @@ -133,6 +134,7 @@ test->object = NULL; test->state = NULL; test->notes = oval_collection_new(); + test->model = model; return test; } @@ -142,15 +144,15 @@ } bool oval_test_is_locked(struct oval_test *test) { - return false;//TODO + return oval_definition_model_is_locked(test->model); } struct oval_test *oval_test_clone - (struct oval_test *old_test, struct oval_definition_model *model) + (struct oval_definition_model *new_model, struct oval_test *old_test) { - struct oval_test *new_test = oval_definition_model_get_test(model, old_test->id); + struct oval_test *new_test = oval_definition_model_get_test(new_model, old_test->id); if(new_test==NULL){ - new_test = oval_test_new(old_test->id); + new_test = oval_test_new(new_model,old_test->id); oval_test_set_deprecated(new_test, old_test->deprecated); oval_test_set_version (new_test, old_test->version); oval_test_set_check (new_test, old_test->check); @@ -159,11 +161,11 @@ oval_test_set_comment (new_test, old_test->comment); if(old_test->object){ - struct oval_object *object = oval_object_clone(old_test->object, model); + struct oval_object *object = oval_object_clone(new_model, old_test->object); oval_test_set_object(new_test, object); } if(old_test->state){ - struct oval_state *state = oval_state_clone(old_test->state, model); + struct oval_state *state = oval_state_clone(new_model, old_test->state); oval_test_set_state(new_test, state); } @@ -174,7 +176,7 @@ } oval_string_iterator_free(notes); - oval_definition_model_add_test(model, new_test); + oval_definition_model_add_test(new_model, new_test); } return new_test; } @@ -198,49 +200,67 @@ void oval_test_set_deprecated(struct oval_test *test, bool deprecated) { - test->deprecated = deprecated; + if(test && !oval_test_is_locked(test)){ + test->deprecated = deprecated; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_version(struct oval_test *test, int version) { - test->version = version; + if(test && !oval_test_is_locked(test)){ + test->version = version; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_subtype(struct oval_test *test, oval_subtype_t subtype) { - test->subtype = subtype; + if(test && !oval_test_is_locked(test)){ + test->subtype = subtype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_comment(struct oval_test *test, char *comm) { - if(test->comment!=NULL)free(test->comment); - test->comment = comm==NULL?NULL:strdup(comm); + if(test && !oval_test_is_locked(test)){ + if(test->comment!=NULL)free(test->comment); + test->comment = comm==NULL?NULL:strdup(comm); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_existence(struct oval_test *test, oval_existence_t existence) { - test->existence = existence; + if(test && !oval_test_is_locked(test)){ + test->existence = existence; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_check(struct oval_test *test, oval_check_t check) { - test->check = check; + if(test && !oval_test_is_locked(test)){ + test->check = check; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_object(struct oval_test *test, struct oval_object *object) { - test->object = object; + if(test && !oval_test_is_locked(test)){ + test->object = object; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_set_state(struct oval_test *test, struct oval_state *state) { - test->state = state; + if(test && !oval_test_is_locked(test)){ + test->state = state; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_test_add_note(struct oval_test *test, char *note) { - oval_collection_add(test->notes, (void *)strdup(note)); + if(test && !oval_test_is_locked(test)){ + oval_collection_add(test->notes, (void *)strdup(note)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_test_parse_notes_consumer(char *text, void *test) { diff -u -r a/src/OVAL/oval_value.c b/src/OVAL/oval_value.c --- a/src/OVAL/oval_value.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_value.c 2009-12-11 14:29:54 -0500 @@ -106,7 +106,7 @@ } bool oval_value_is_locked(struct oval_value *value) { - return false;//TODO + return true;//oval_value is intrinsically locked } struct oval_value *oval_value_clone(struct oval_value *old_value) @@ -124,33 +124,23 @@ } } + +/* void oval_value_set_datatype(struct oval_value *value, oval_datatype_t datatype) { - value->datatype = datatype; + if(value && !oval_value_is_locked(value)){ + value->datatype = datatype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } - void oval_value_set_text(struct oval_value *value, char *text) { - if(value->text!=NULL)free(value->text); - value->text = ((text==NULL)?NULL:strdup(text)); -} - -void oval_value_set_float(struct oval_value *value, float num) { /* TODO */ - //TODO::VALUE -} - -void oval_value_set_boolean(struct oval_value *value, int b) { /* TODO */ - //TODO::VALUE -} - -void oval_value_set_binary(struct oval_value *value, unsigned char *num) { /* TODO */ - //TODO::VALUE -} - -void oval_value_set_integer(struct oval_value *value, long num) { /* TODO */ - //TODO::VALUE + if(value && !oval_value_is_locked(value)){ + if(value->text!=NULL)free(value->text); + value->text = ((text==NULL)?NULL:strdup(text)); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } +*/ static void oval_value_parse_tag_consume_text(char *string, void *text) { *(char**)text = strdup(string); diff -u -r a/src/OVAL/oval_varModel.c b/src/OVAL/oval_varModel.c --- a/src/OVAL/oval_varModel.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_varModel.c 2009-12-11 14:01:40 -0500 @@ -53,16 +53,21 @@ return frame; } +typedef struct oval_variable_model { + struct oval_string_map *varmap; + bool is_locked; +} oval_variable_model_t; + bool oval_variable_model_is_valid(struct oval_variable_model *variable_model) { return true;//TODO } bool oval_variable_model_is_locked(struct oval_variable_model *variable_model) { - return false;//TODO + return variable_model->is_locked; } void oval_variable_model_lock(struct oval_variable_model *variable_model){ - //TODO + variable_model->is_locked = true; } void _oval_variable_model_frame_free(_oval_variable_model_frame_t *frame) @@ -80,14 +85,11 @@ } -typedef struct oval_variable_model { - struct oval_string_map *varmap; -} oval_variable_model_t; - struct oval_variable_model *oval_variable_model_new() { oval_variable_model_t *model = (oval_variable_model_t *)malloc(sizeof(oval_variable_model_t)); model->varmap = oval_string_map_new(); + model->is_locked = false; return model; } diff -u -r a/src/OVAL/oval_variable.c b/src/OVAL/oval_variable.c --- a/src/OVAL/oval_variable.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_variable.c 2009-12-11 15:00:26 -0500 @@ -37,6 +37,7 @@ typedef struct oval_variable { + struct oval_definition_model *model; char *id; char *comment; int version; @@ -48,6 +49,7 @@ } oval_variable_t, oval_variable_CONEXT_t; typedef struct oval_variable_LOCAL { + struct oval_definition_model *model; char *id; char *comment; int version; @@ -156,7 +158,7 @@ } - struct oval_variable *oval_variable_new(char *id, oval_variable_type_t type) +struct oval_variable *oval_variable_new(struct oval_definition_model *model, char *id, oval_variable_type_t type) { oval_variable_t *variable; switch(type){ @@ -196,6 +198,7 @@ return NULL; } + variable->model = model; variable->id = strdup(id); variable->comment = NULL; variable->datatype = OVAL_DATATYPE_UNKNOWN; @@ -209,15 +212,15 @@ } bool oval_variable_is_locked(struct oval_variable *variable) { - return false;//TODO + return oval_definition_model_is_locked(variable->model); } struct oval_variable *oval_variable_clone - (struct oval_variable *old_variable, struct oval_definition_model *model) + (struct oval_definition_model* new_model, struct oval_variable *old_variable) { - oval_variable_t *new_variable = oval_definition_model_get_variable(model, old_variable->id); + oval_variable_t *new_variable = oval_definition_model_get_variable(new_model, old_variable->id); if(new_variable==NULL){ - new_variable = oval_variable_new(old_variable->id, old_variable->type); + new_variable = oval_variable_new(new_model, old_variable->id, old_variable->type); oval_variable_set_comment (new_variable, old_variable->comment); oval_variable_set_version (new_variable, old_variable->version); @@ -238,9 +241,9 @@ if(new_variable->type==OVAL_VARIABLE_LOCAL){ struct oval_component *component = oval_variable_get_component(old_variable); - oval_variable_set_component(new_variable, oval_component_clone(component, model)); + oval_variable_set_component(new_variable, oval_component_clone(new_model, component)); } - oval_definition_model_add_variable(model, new_variable); + oval_definition_model_add_variable(new_model, new_variable); } return new_variable; } @@ -273,69 +276,83 @@ void oval_variable_set_datatype(struct oval_variable *variable, oval_datatype_t datatype) { - variable->datatype = datatype; + if(variable && !oval_variable_is_locked(variable)){ + variable->datatype = datatype; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_set_type(struct oval_variable *variable, oval_variable_type_t type) { - if(variable->type==OVAL_VARIABLE_UNKNOWN){ - variable->type = type; - switch(type){ - case OVAL_VARIABLE_CONSTANT: - case OVAL_VARIABLE_EXTERNAL: + if(variable && !oval_variable_is_locked(variable)){ + if(variable->type==OVAL_VARIABLE_UNKNOWN){ + variable->type = type; + switch(type){ + case OVAL_VARIABLE_CONSTANT: + case OVAL_VARIABLE_EXTERNAL: { oval_variable_CONEXT_t *conext = (oval_variable_CONEXT_t *)variable; conext->values = oval_collection_new(); conext->flag = SYSCHAR_FLAG_NOT_COLLECTED; }break; - case OVAL_VARIABLE_LOCAL: - case OVAL_VARIABLE_UNKNOWN: - variable->flag = SYSCHAR_FLAG_UNKNOWN;break; - } - }else if (variable->type != type){ - fprintf(stderr, "ERROR: attempt to reset valid variable type\n oldtype = %s\n newtype = %s", - oval_variable_type_get_text(variable->type), oval_variable_type_get_text(type)); - } + case OVAL_VARIABLE_LOCAL: + case OVAL_VARIABLE_UNKNOWN: + variable->flag = SYSCHAR_FLAG_UNKNOWN;break; + } + }else if (variable->type != type){ + fprintf(stderr, "ERROR: attempt to reset valid variable type\n oldtype = %s\n newtype = %s", + oval_variable_type_get_text(variable->type), oval_variable_type_get_text(type)); + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_set_comment(struct oval_variable *variable, char *comm) { - if(variable->comment!=NULL)free(variable->comment); - variable->comment = comm==NULL?NULL:strdup(comm); + if(variable && !oval_variable_is_locked(variable)){ + if(variable->comment!=NULL)free(variable->comment); + variable->comment = comm==NULL?NULL:strdup(comm); + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_set_deprecated(struct oval_variable *variable, bool deprecated) { - variable->deprecated = deprecated; + if(variable && !oval_variable_is_locked(variable)){ + variable->deprecated = deprecated; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_set_version(struct oval_variable *variable, int version) { - variable->version = version; + if(variable && !oval_variable_is_locked(variable)){ + variable->version = version; + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_add_value(struct oval_variable *variable, struct oval_value *value) { //type==OVAL_VARIABLE_CONSTANT - if (variable->type == OVAL_VARIABLE_CONSTANT || variable->type == OVAL_VARIABLE_EXTERNAL) { - char *text = oval_value_get_text(value); - oval_collection_add(variable->values, value); - variable->flag = SYSCHAR_FLAG_COMPLETE; - } + if(variable && !oval_variable_is_locked(variable)){ + if (variable->type == OVAL_VARIABLE_CONSTANT || variable->type == OVAL_VARIABLE_EXTERNAL) { + char *text = oval_value_get_text(value); + oval_collection_add(variable->values, value); + variable->flag = SYSCHAR_FLAG_COMPLETE; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } void oval_variable_set_component(struct oval_variable *variable, struct oval_component *component) { - //type==OVAL_VARIABLE_LOCAL - if (variable->type == OVAL_VARIABLE_LOCAL) { - oval_variable_LOCAL_t *local = - (oval_variable_LOCAL_t *) variable; - local->component = component; - } + if(variable && !oval_variable_is_locked(variable)){ + //type==OVAL_VARIABLE_LOCAL + if (variable->type == OVAL_VARIABLE_LOCAL) { + oval_variable_LOCAL_t *local = + (oval_variable_LOCAL_t *) variable; + local->component = component; + } + }else fprintf(stderr, "WARNING: attempt to update locked content\n %s(%d)\n", __FILE__, __LINE__); } static void _oval_variable_parse_local_tag_component_consumer(struct oval_component *component, void *variable) { @@ -372,7 +389,6 @@ struct oval_parser_context *context, struct oval_variable *variable) { - fprintf(stderr,"DEBUG:: %s(%d)\n", __FILE__, __LINE__); char *text_value = NULL; xmlChar *tagname = xmlTextReaderName(reader); xmlChar *namespace = xmlTextReaderNamespaceUri(reader); @@ -396,7 +412,6 @@ int oval_variable_parse_tag(xmlTextReaderPtr reader, struct oval_parser_context *context) { - fprintf(stderr,"DEBUG:: %s(%d)\n", __FILE__, __LINE__); struct oval_definition_model *model = oval_parser_context_model(context); char *tagname = (char*) xmlTextReaderName(reader); oval_variable_type_t type; @@ -557,7 +572,6 @@ xmlNode *oval_variable_to_dom (struct oval_variable *variable, xmlDoc *doc, xmlNode *parent) { - fprintf(stderr,"DEBUG:: %s(%d)\n", __FILE__, __LINE__); xmlNode *variable_node = NULL; switch(oval_variable_get_type(variable)) { diff -u -r a/src/OVAL/oval_variableBinding.c b/src/OVAL/oval_variableBinding.c --- a/src/OVAL/oval_variableBinding.c 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/oval_variableBinding.c 2009-12-10 14:33:26 -0500 @@ -100,7 +100,7 @@ struct oval_variable *old_variable = oval_variable_binding_get_variable(old_binding); char *varid = oval_variable_get_id(old_variable); struct oval_variable *new_variable = oval_definition_model_get_variable(def_model, varid); - if(new_variable==NULL)oval_variable_clone(old_variable, def_model); + if(new_variable==NULL)oval_variable_clone(def_model, old_variable); char *old_value = oval_variable_binding_get_value(old_binding); char *new_value = (old_value)?strdup(old_value):NULL; diff -u -r a/src/OVAL/public/oval_definitions.h b/src/OVAL/public/oval_definitions.h --- a/src/OVAL/public/oval_definitions.h 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/public/oval_definitions.h 2009-12-11 13:59:30 -0500 @@ -1136,12 +1136,12 @@ * Construct instance of @ref Oval_affected. * @ingroup Oval_affected */ -struct oval_affected *oval_affected_new(void); +struct oval_affected *oval_affected_new(struct oval_definition_model *); /** * Clone instance of @ref Oval_affected. * @ingroup Oval_affected */ -struct oval_affected *oval_affected_clone(struct oval_affected *); +struct oval_affected *oval_affected_clone(struct oval_definition_model *new_model, struct oval_affected *old_affected); /** * Returns true * @ingroup oval_affected_eval @@ -1218,12 +1218,13 @@ * @param type - the required node type. * @ingroup Oval_criteria_node */ -struct oval_criteria_node *oval_criteria_node_new(oval_criteria_node_type_t type); +struct oval_criteria_node *oval_criteria_node_new(struct oval_definition_model *, oval_criteria_node_type_t type); /** * Clone an instance of @ref Oval_criteria_node. * @ingroup Oval_criteria_node */ -struct oval_criteria_node *oval_criteria_node_clone(struct oval_criteria_node *, struct oval_definition_model *); +struct oval_criteria_node *oval_criteria_node_clone +(struct oval_definition_model *new_model, struct oval_criteria_node *old_node); /** * Return true if the instance of Oval_criteria_node is locked. * The state of a locked instance cannot be changed. @@ -1371,7 +1372,7 @@ /** * @ingroup oval_reference */ -struct oval_reference *oval_reference_new(void); +struct oval_reference *oval_reference_new(struct oval_definition_model*); /** * return true if the reference instance is valid * @ingroup oval_reference_eval @@ -1386,7 +1387,8 @@ /** * @ingroup oval_reference */ -struct oval_reference *oval_reference_clone(struct oval_reference *); +struct oval_reference *oval_reference_clone +(struct oval_definition_model *new_model, struct oval_reference *old_reference); /** * @ingroup oval_reference */ @@ -1450,7 +1452,7 @@ * @param id - (non-NULL) A copy of this string is bound to the id attribute of the created instance. * @ingroup Oval_definition */ -struct oval_definition *oval_definition_new(char *id); +struct oval_definition *oval_definition_new(struct oval_definition_model *, char *id); /** * Release an instance of @ref Oval_definition. * All attributes of the Oval_definition are also released. @@ -1679,7 +1681,7 @@ * @param id - (Not NULL) the text of the required object id. * @ingroup Oval_object */ -struct oval_object *oval_object_new(char *id); +struct oval_object *oval_object_new(struct oval_definition_model *, char *id); /** * return true if the object instance is valid * @ingroup oval_object_eval @@ -1711,6 +1713,13 @@ const char *oval_object_get_name (struct oval_object *); /** + * Probe single OVAL object. + * TODO: GET THIS RIGHT + * @ingroup oval_object_eval + */ +struct oval_syschar *oval_object_probe(struct oval_object *, struct oval_definition_model *model); + +/** * Returns attribute @ref Oval_object->subtype * @see oval_object_set_subtype * @ingroup oval_object_getters @@ -1868,7 +1877,7 @@ * @param id - (Not NULL) the text of the required test id. * @ingroup Oval_test */ -struct oval_test *oval_test_new(char *id); +struct oval_test *oval_test_new(struct oval_definition_model *, char *id); /** * Construct instance of @ref Oval_test. * @ingroup Oval_test @@ -2118,7 +2127,8 @@ /** * @ingroup Oval_object_content */ -struct oval_object_content *oval_object_content_new(oval_object_content_type_t type); +struct oval_object_content + *oval_object_content_new(struct oval_definition_model *model, oval_object_content_type_t type); /** * return true if the object_content instance is valid * @ingroup oval_object_content_eval @@ -2133,7 +2143,8 @@ /** * @ingroup Oval_object_content */ -struct oval_object_content *oval_object_content_clone(struct oval_object_content *, struct oval_definition_model *); +struct oval_object_content *oval_object_content_clone +(struct oval_definition_model *new_model, struct oval_object_content *old_content); /** * @ingroup Oval_object_content */ @@ -2203,7 +2214,7 @@ /** * @ingroup Oval_state_content */ -struct oval_state_content *oval_state_content_new(void); +struct oval_state_content *oval_state_content_new(struct oval_definition_model *); /** * return true if the state instance is valid * @ingroup oval_state_eval @@ -2218,7 +2229,8 @@ /** * @ingroup Oval_state_content */ -struct oval_state_content *oval_state_content_clone(struct oval_state_content *, struct oval_definition_model *); +struct oval_state_content *oval_state_content_clone +(struct oval_definition_model *new_model, struct oval_state_content *old_content); /** * @ingroup Oval_state_content */ @@ -2238,7 +2250,7 @@ /** * @ingroup Oval_entity */ -struct oval_entity *oval_entity_new(void); +struct oval_entity *oval_entity_new(struct oval_definition_model *); /** * return true if the entity instance is valid * @ingroup oval_entity_eval @@ -2253,7 +2265,8 @@ /** * @ingroup Oval_entity */ -struct oval_entity *oval_entity_clone(struct oval_entity *, struct oval_definition_model *); +struct oval_entity *oval_entity_clone +(struct oval_definition_model *model, struct oval_entity *old_entity); /** * @ingroup Oval_entity */ @@ -2375,7 +2388,7 @@ /** * @ingroup Oval_setobject */ -struct oval_setobject *oval_setobject_new(void); +struct oval_setobject *oval_setobject_new(struct oval_definition_model *); /** * return true if the setobject instance is valid * @ingroup oval_setobject_eval @@ -2390,7 +2403,8 @@ /** * @ingroup Oval_setobject */ -struct oval_setobject *oval_setobject_clone(struct oval_setobject *, struct oval_definition_model *); +struct oval_setobject *oval_setobject_clone +(struct oval_definition_model *new_model, struct oval_setobject *old_setobject); /** * @ingroup Oval_setobject */ @@ -2458,7 +2472,7 @@ /** * @ingroup Oval_behavior */ -struct oval_behavior *oval_behavior_new(void); +struct oval_behavior *oval_behavior_new(struct oval_definition_model *); /** * return true if the behavior instance is valid * @ingroup oval_behavior_eval @@ -2473,7 +2487,7 @@ /** * @ingroup Oval_behavior */ -struct oval_behavior *oval_behavior_clone(struct oval_behavior *); +struct oval_behavior *oval_behavior_clone(struct oval_definition_model *new_model, struct oval_behavior *old_behavior); /** * @ingroup Oval_behavior */ @@ -2522,36 +2536,12 @@ /** * @ingroup Oval_value */ -struct oval_value *oval_value_clone(struct oval_value *); +struct oval_value *oval_value_clone(struct oval_value *old_value); /** * @ingroup Oval_value */ void oval_value_free(struct oval_value *); /** - * @ingroup oval_value_setters - */ -void oval_value_set_datatype(struct oval_value *, oval_datatype_t); -/** - * @ingroup oval_value_setters - */ -void oval_value_set_text(struct oval_value *, char *); -/** - * @ingroup oval_value_setters - */ -void oval_value_set_binary(struct oval_value *, unsigned char *); //datatype==OVAL_DATATYPE_BINARY -/** - * @ingroup oval_value_setters - */ -void oval_value_set_boolean(struct oval_value *, int); //datatype==OVAL_DATATYPE_BOOLEAN -/** - * @ingroup oval_value_setters - */ -void oval_value_set_float(struct oval_value *, float); //datatype==OVAL_DATATYPE_FLOAT -/** - * @ingroup oval_value_setters - */ -void oval_value_set_integer(struct oval_value *, long); //datatype==OVAL_DATATYPE_INTEGER -/** * @ingroup oval_value_iterators */ bool oval_value_iterator_has_more(struct oval_value_iterator *); @@ -2610,7 +2600,7 @@ * @param id - (Not NULL) the text of the required state id. * @ingroup Oval_state */ -struct oval_state *oval_state_new(char *id); +struct oval_state *oval_state_new(struct oval_definition_model *, char *id); /** * return true if the state instance is valid * @ingroup oval_state_eval @@ -2800,7 +2790,7 @@ * @param type - (Not @ref OVAL_VARIABLE_UNKNOWN) the required type. * @ingroup Oval_variable */ -struct oval_variable *oval_variable_new(char * id, oval_variable_type_t type); +struct oval_variable *oval_variable_new(struct oval_definition_model *model, char *id, oval_variable_type_t type); /** * Free instance of @ref Oval_variable. * @ingroup Oval_variable @@ -2976,12 +2966,12 @@ * @param type - the required component type. * @ingroup Oval_component */ -struct oval_component *oval_component_new(oval_component_type_t type); +struct oval_component *oval_component_new(struct oval_definition_model *, oval_component_type_t type); /** * Clone instance of @ref Oval_component. * @ingroup Oval_component */ -struct oval_component *oval_component_clone(struct oval_component *, struct oval_definition_model *); +struct oval_component *oval_component_clone(struct oval_definition_model *new_model, struct oval_component *old_component); /** * Returns true if the @ref Oval_component is valid. * An Oval_component is valid if one of the following is true: diff -u -r a/src/OVAL/public/oval_results.h b/src/OVAL/public/oval_results.h --- a/src/OVAL/public/oval_results.h 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/public/oval_results.h 2009-12-10 14:13:57 -0500 @@ -373,7 +373,7 @@ * Create new OVAL results directives. * @ingroup Oval_result_directives */ -struct oval_result_directives *oval_result_directives_new(void); +struct oval_result_directives *oval_result_directives_new(struct oval_results_model *); /** * return true if the result_directives instance is valid * @ingroup oval_result_directives_eval @@ -610,7 +610,7 @@ /** * @ingroup Oval_result_system */ -struct oval_result_system *oval_result_system_new(struct oval_syschar_model *); +struct oval_result_system *oval_result_system_new(struct oval_results_model *, struct oval_syschar_model *); /** * return true if the result_system instance is valid * @ingroup oval_result_system_eval @@ -625,7 +625,7 @@ /** * @ingroup Oval_result_system */ -struct oval_result_system *oval_result_system_clone(struct oval_result_system *old_system, struct oval_results_model *new_model); +struct oval_result_system *oval_result_system_clone(struct oval_results_model *new_model, struct oval_result_system *old_system); /** * @ingroup Oval_result_system */ @@ -648,7 +648,8 @@ /** * @ingroup Oval_result_definition */ -struct oval_result_definition *oval_result_definition_clone(struct oval_result_definition *old_definition, struct oval_result_system *new_system); +struct oval_result_definition *oval_result_definition_clone +(struct oval_result_system *new_system, struct oval_result_definition *old_definition); /** * @ingroup Oval_result_definition */ @@ -671,7 +672,8 @@ /** * @ingroup Oval_result_test */ -struct oval_result_test *oval_result_test_clone(struct oval_result_test *old_test, struct oval_result_system *system); +struct oval_result_test *oval_result_test_clone +(struct oval_result_system *new_system, struct oval_result_test *old_test); /** * @ingroup Oval_result_test */ @@ -694,7 +696,8 @@ /** * @ingroup Oval_result_item */ -struct oval_result_item *oval_result_item_clone(struct oval_result_item *old_item, struct oval_result_system *new_system); +struct oval_result_item *oval_result_item_clone +(struct oval_result_system *new_system, struct oval_result_item *old_item); /** * @ingroup Oval_result_item */ @@ -730,7 +733,7 @@ /** * @ingroup Oval_result_criteria_node */ -struct oval_result_criteria_node *oval_result_criteria_node_new(oval_criteria_node_type_t, int, ...); +struct oval_result_criteria_node *oval_result_criteria_node_new(struct oval_result_system *, oval_criteria_node_type_t, int, ...); /** * return true if the result_criteria_node instance is valid * @ingroup oval_result_criteria_node_eval @@ -745,7 +748,8 @@ /** * @ingroup Oval_result_criteria_node */ -struct oval_result_criteria_node *oval_result_criteria_node_clone(struct oval_result_criteria_node *old_node, struct oval_result_system *new_system); +struct oval_result_criteria_node *oval_result_criteria_node_clone +(struct oval_result_system *new_system, struct oval_result_criteria_node *old_node); /** * @ingroup Oval_result_criteria_node */ diff -u -r a/src/OVAL/public/oval_system_characteristics.h b/src/OVAL/public/oval_system_characteristics.h --- a/src/OVAL/public/oval_system_characteristics.h 2009-12-11 11:40:26 -0500 +++ b/src/OVAL/public/oval_system_characteristics.h 2009-12-11 09:59:02 -0500 @@ -408,11 +408,9 @@ * Load OVAL system characteristics from a file. * @ingroup OVALSYS_service */ -void oval_syschar_model_import(struct oval_syschar_model*, struct oval_import_source*, - oval_xml_error_handler, void*); - - - +void oval_syschar_model_import(struct oval_syschar_model *model, + struct oval_import_source *source, + oval_xml_error_handler eh, void *user_arg ); /** * @ingroup oval_sysint_iterators @@ -626,7 +624,7 @@ /** * @ingroup Oval_sysint */ -struct oval_sysint *oval_sysint_new(void); +struct oval_sysint *oval_sysint_new(struct oval_syschar_model *); /** * return true if the sysint instance is valid * @ingroup oval_sysint_eval @@ -641,7 +639,7 @@ /** * @ingroup Oval_sysint */ -struct oval_sysint *oval_sysint_clone(struct oval_sysint *); +struct oval_sysint *oval_sysint_clone(struct oval_syschar_model *new_model, struct oval_sysint *old_sysint); /** * @ingroup Oval_sysint */ @@ -661,7 +659,7 @@ /** * @ingroup Oval_sysinfo */ -struct oval_sysinfo *oval_sysinfo_new(void); +struct oval_sysinfo *oval_sysinfo_new(struct oval_syschar_model *); /** * return true if the sysinfo instance is valid * @ingroup oval_sysinfo_eval @@ -676,7 +674,7 @@ /** * @ingroup Oval_sysinfo */ -struct oval_sysinfo *oval_sysinfo_clone(struct oval_sysinfo *); +struct oval_sysinfo *oval_sysinfo_clone(struct oval_syschar_model *new_model, struct oval_sysinfo *old_sysinfo); /** * @ingroup Oval_sysinfo */ @@ -704,7 +702,7 @@ /** * @ingroup Oval_sysdata */ -struct oval_sysdata *oval_sysdata_new(char *id); +struct oval_sysdata *oval_sysdata_new(struct oval_syschar_model *, char *id); /** * return true if the sysdata instance is valid * @ingroup oval_sysdata_eval @@ -719,7 +717,7 @@ /** * @ingroup Oval_sysdata */ -struct oval_sysdata *oval_sysdata_clone(struct oval_sysdata *old_data, struct oval_syschar_model *model); +struct oval_sysdata *oval_sysdata_clone(struct oval_syschar_model *new_model, struct oval_sysdata *old_data); /** * @ingroup Oval_sysdata */ @@ -747,7 +745,7 @@ /** * @ingroup Oval_syschar */ -struct oval_syschar *oval_syschar_new(struct oval_object *); +struct oval_syschar *oval_syschar_new(struct oval_syschar_model *, struct oval_object *); /** * return true if the syschar instance is valid * @ingroup oval_syschar_eval @@ -762,7 +760,7 @@ /** * @ingroup Oval_syschar */ -struct oval_syschar *oval_syschar_clone(struct oval_syschar *old_syschar, struct oval_syschar_model *sys_model); +struct oval_syschar *oval_syschar_clone(struct oval_syschar_model *new_model, struct oval_syschar *old_syschar); /** * @ingroup Oval_syschar */ @@ -790,7 +788,7 @@ /** * @ingroup Oval_sysitem */ -struct oval_sysitem *oval_sysitem_new(void); +struct oval_sysitem *oval_sysitem_new(struct oval_syschar_model *); /** * return true if the sysitem instance is valid * @ingroup oval_sysitem_eval @@ -805,7 +803,7 @@ /** * @ingroup Oval_sysitem */ -struct oval_sysitem *oval_sysitem_clone(struct oval_sysitem *old_item); +struct oval_sysitem *oval_sysitem_clone(struct oval_syschar_model *new_model, struct oval_sysitem *old_item); /** * @ingroup Oval_sysitem */ diff -u -r a/src/common/util.h b/src/common/util.h --- a/src/common/util.h 2009-12-11 11:40:26 -0500 +++ b/src/common/util.h 2009-11-24 12:14:50 -0500 @@ -29,11 +29,8 @@ #define OSCAP_UTIL_H_ #include -#include #include "public/alloc.h" -#define __attribute__nonnull__(x) assert((x) != NULL) - struct oscap_import_source; struct oscap_export_target; diff -u -r a/tests/OVAL/SEAP/test_sexp_to_syschar.c b/tests/OVAL/SEAP/test_sexp_to_syschar.c --- a/tests/OVAL/SEAP/test_sexp_to_syschar.c 2009-12-11 11:40:26 -0500 +++ b/tests/OVAL/SEAP/test_sexp_to_syschar.c 2009-12-11 16:34:50 -0500 @@ -52,7 +52,7 @@ SEXP_printfa(probe_out); printf("\n\n"); - struct oval_syschar* syschar = oval_syschar_new(NULL); + struct oval_syschar* syschar = oval_syschar_new(NULL, NULL);//NOTE NEW API FOR oval_syschar_new oval_syschar_apply_sexp(syschar, probe_out, NULL); diff -u -r a/tests/OVAL/probes/test_probes.c b/tests/OVAL/probes/test_probes.c --- a/tests/OVAL/probes/test_probes.c 2009-12-11 11:40:26 -0500 +++ b/tests/OVAL/probes/test_probes.c 2009-12-11 16:32:54 -0500 @@ -79,7 +79,7 @@ syschar = oval_probe_object_eval(pctx, object); if (syschar == NULL) { - syschar = oval_syschar_new(object); + syschar = oval_syschar_new(syschar_model, object); oval_syschar_set_flag(syschar, SYSCHAR_FLAG_NOT_COLLECTED); } diff -u -r a/tests/OVAL/probes/test_probes.sh b/tests/OVAL/probes/test_probes.sh --- a/tests/OVAL/probes/test_probes.sh 2009-12-11 11:40:26 -0500 +++ b/tests/OVAL/probes/test_probes.sh 2009-12-09 12:37:11 -0500 @@ -56,9 +56,9 @@ if [ $ret_val -eq 0 ]; then grep -q "os_name: `uname`" ${srcdir}/test_probes_tc02.out || ret_val=1 grep -q "os_version: `uname -v`" ${srcdir}/test_probes_tc02.out || ret_val=1 - grep -q "os_architecture: `uname -m`" ${srcdir}/test_probes_tc02.out || ret_val=1 + grep -q "os_architecture: `uname -i`" ${srcdir}/test_probes_tc02.out || ret_val=1 grep -q "primary_host_name: `uname -n`" ${srcdir}/test_probes_tc02.out || ret_val=1 - for i in `sed -n '6,$p' ${srcdir}/test_probes_tc02.out | awk '{print $1}'`; do + for i in `sed -n '5,$p' ${srcdir}/test_probes_tc02.out | awk '{print $1}'`; do IPV4=`ifconfig $i | sed 's/ /\n/g' | grep "inet " | sed 's/addr://' | awk '{print $2}' | sed 's/\/.*$//'` IPV6=`ifconfig $i | sed 's/ /\n/g' | grep "inet6 " | sed 's/addr://' | awk '{print $2}' | sed 's/\/.*$//'` grep "$IPV4" ${srcdir}/test_probes_tc02.out | grep -q $i || ret_val=1 diff -u -r a/tests/OVAL/test_results.c b/tests/OVAL/test_results.c --- a/tests/OVAL/test_results.c 2009-12-11 11:40:26 -0500 +++ b/tests/OVAL/test_results.c 2009-12-11 16:39:12 -0500 @@ -52,7 +52,7 @@ printf("OVAL RESULTS LOADED\n"); if (argc>3) { printf("WRITE OVAL RESULTS\n"); - struct oval_result_directives *directives = oval_result_directives_new(); + struct oval_result_directives *directives = oval_result_directives_new(results_model); struct oval_export_target* target = oval_export_target_new_file(argv[3], "UTF-8"); oval_results_model_export(results_model, directives, target); oval_export_target_free(target);