From: Jennifer Richards Date: Sat, 9 Sep 2017 00:05:31 +0000 (-0400) Subject: Validate arguments in helper function, fix whitespace issue X-Git-Tag: v3.0.2~6 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=commitdiff_plain;h=1bc0686d5cb47a8455834609c2f2cd694de5bc1f Validate arguments in helper function, fix whitespace issue --- diff --git a/common/tr_config.c b/common/tr_config.c index b0162b6..bdbe2a3 100644 --- a/common/tr_config.c +++ b/common/tr_config.c @@ -2067,13 +2067,14 @@ typedef TR_CFG_RC (TR_CFG_PARSE_FN)(TR_CFG *, json_t *); * @param parse_fn Function to apply * @return TR_CFG_SUCCESS on success, _FAIL or an error code on failure */ -static TR_CFG_RC tr_cfg_parse_helper(TR_CFG *cfg, json_t **jcfgs, size_t n_jcfg, TR_CFG_PARSE_FN parse_fn) +static TR_CFG_RC tr_cfg_parse_helper(TR_CFG *cfg, unsigned int n_jcfg, json_t **jcfgs, TR_CFG_PARSE_FN parse_fn) { size_t ii=0; json_t *this_jcfg=NULL; TR_CFG_RC ret=TR_CFG_ERROR; - /* TODO validate arguments */ + if ((cfg==NULL) || (jcfgs==NULL) || (parse_fn==NULL)) + return TR_CFG_ERROR; for (ii=0; iinew->peers=trp_ptable_new(cfg_mgr); /* not sure why this isn't in cfg_mgr->new's context */ /* now run through the parsers on the JSON */ - if ((TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, jcfgs, n_files, tr_cfg_parse_internal))) || - (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, jcfgs, n_files, tr_cfg_parse_local_orgs))) || - (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, jcfgs, n_files, tr_cfg_parse_peer_orgs))) || - (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, jcfgs, n_files, tr_cfg_parse_default_servers))) || - (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, jcfgs, n_files, tr_cfg_parse_comms)))) + if ((TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, n_files, jcfgs, tr_cfg_parse_internal))) || + (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, n_files, jcfgs, tr_cfg_parse_local_orgs))) || + (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, n_files, jcfgs, tr_cfg_parse_peer_orgs))) || + (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, n_files, jcfgs, tr_cfg_parse_default_servers))) || + (TR_CFG_SUCCESS != (cfg_rc=tr_cfg_parse_helper(cfg_mgr->new, n_files, jcfgs, tr_cfg_parse_comms)))) goto cleanup; /* cfg_rc was set above */ /* make sure we got a complete, consistent configuration */