# HG changeset patch # User Sebastien Decugis # Date 1243848048 -32400 # Node ID f0ba4fa1665ebf11eb09fb7f0f727d6afea5e653 # Parent b1eb38915f0451fecbfd5a97b6dd0b5387b7395a Fixed couple of possible issues diff -r b1eb38915f04 -r f0ba4fa1665e waaad/dict-base.c --- a/waaad/dict-base.c Fri May 29 18:00:51 2009 +0900 +++ b/waaad/dict-base.c Mon Jun 01 18:20:48 2009 +0900 @@ -152,8 +152,12 @@ #define CHECK_dict_new( _type, _data, _parent, _ref ) \ CHECK_FCT( dict_new( (_type), (_data), (_parent), (_ref)) ); -#define CHECK_dict_search( _type, _criteria, _what, _result ) \ - CHECK_FCT( dict_search( (_type), (_criteria), (_what), (_result)) ); +#define CHECK_dict_search( _type, _criteria, _what, _result ) \ + CHECK_FCT( dict_search( (_type), (_criteria), (_what), (_result)) ); \ + if ( !*(_result) ) { \ + TRACE_DEBUG(INFO, "Not found: "#_type ", "#_criteria", "#_what", "#_result ); \ + return ENOENT; \ + } typedef struct { char *avp_name; @@ -175,11 +179,21 @@ (_rulearray)[__ar].max, \ (_rulearray)[__ar].template}; \ __data.rule_order = RULE_ORDER(__data.rule_position); \ - CHECK_dict_search( DICT_AVP, \ + CHECK_FCT( dict_search( \ + DICT_AVP, \ AVP_BY_NAME, \ (_rulearray)[__ar].avp_name, \ - &__data.rule_avp ); \ - CHECK_dict_new( DICT_RULE, &__data, _parent, NULL); \ + &__data.rule_avp ) ); \ + if ( !__data.rule_avp ) { \ + TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name ); \ + return ENOENT; \ + } \ + CHECK_FCT_DO( dict_new( DICT_RULE, &__data, _parent, NULL), \ + { \ + TRACE_DEBUG(INFO, "Error on rule with AVP '%s'", \ + (_rulearray)[__ar].avp_name ); \ + return EINVAL; \ + } ); \ } \ } diff -r b1eb38915f04 -r f0ba4fa1665e waaad/dictionary.c --- a/waaad/dictionary.c Fri May 29 18:00:51 2009 +0900 +++ b/waaad/dictionary.c Mon Jun 01 18:20:48 2009 +0900 @@ -1405,6 +1405,12 @@ } } + /* For RULE object, we must also check that the "avp" referenced exists */ + if (type == DICT_RULE) { + CHECK_PARAMS( verify_object(((dict_rule_data_t *)data)->rule_avp) ); + CHECK_PARAMS( _O(((dict_rule_data_t *)data)->rule_avp)->type == DICT_AVP ); + } + /* For COMMAND object, check that the 'R' flag is fixed */ if (type == DICT_COMMAND) { CHECK_PARAMS( ((dict_cmd_data_t *)data)->cmd_flag_mask & CMD_FLAG_REQUEST );