Adjusted code to not rely on COMPAT_6_5 API
Leak in optimize xpath code
This commit is contained in:
parent
d3587b8646
commit
59b3100704
5 changed files with 31 additions and 25 deletions
|
|
@ -116,6 +116,9 @@ int clixon_err_restore(void *handle);
|
||||||
int clixon_err_cat_reg(enum clixon_err category, void *handle, clixon_cat_log_cb logfn);
|
int clixon_err_cat_reg(enum clixon_err category, void *handle, clixon_cat_log_cb logfn);
|
||||||
int clixon_err_exit(void);
|
int clixon_err_exit(void);
|
||||||
|
|
||||||
|
/* doesnt work if arg != NULL */
|
||||||
|
#define clixon_netconf_error(h, x, f, a) clixon_err_fn((h), __FUNCTION__, __LINE__, OE_XML, 0,(x), (f))
|
||||||
|
|
||||||
#if 1 /* COMPAT_6_5 */
|
#if 1 /* COMPAT_6_5 */
|
||||||
#define clicon_err(c,s,_fmt, args...) clixon_err_fn(NULL, __FUNCTION__, __LINE__, (c), (s), NULL, _fmt , ##args)
|
#define clicon_err(c,s,_fmt, args...) clixon_err_fn(NULL, __FUNCTION__, __LINE__, (c), (s), NULL, _fmt , ##args)
|
||||||
#define clicon_err_reset() clixon_err_reset()
|
#define clicon_err_reset() clixon_err_reset()
|
||||||
|
|
@ -124,9 +127,7 @@ int clixon_err_exit(void);
|
||||||
#define clicon_suberrno clixon_err_subnr()
|
#define clicon_suberrno clixon_err_subnr()
|
||||||
#define clicon_err_reason clixon_err_reason()
|
#define clicon_err_reason clixon_err_reason()
|
||||||
|
|
||||||
/* doesnt work if arg != NULL */
|
|
||||||
#define clixon_netconf_error(h, x, f, a) clixon_err_fn((h), __FUNCTION__, __LINE__, OE_XML, 0,(x), (f) , NULL)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CLIXON_ERR_H_ */
|
#endif /* _CLIXON_ERR_H_ */
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ clixon_err_args(clixon_handle h,
|
||||||
* printf("%s", cbuf_get(cb));
|
* printf("%s", cbuf_get(cb));
|
||||||
* cbuf_free(cb);
|
* cbuf_free(cb);
|
||||||
* @endcode
|
* @endcode
|
||||||
* @see clixon_err_netconf_fn
|
* @see clixon_error_netconf
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
netconf_err2cb(clixon_handle h,
|
netconf_err2cb(clixon_handle h,
|
||||||
|
|
@ -409,7 +409,7 @@ netconf_err2cb(clixon_handle h,
|
||||||
* @param[in] format Error string, format with argv
|
* @param[in] format Error string, format with argv
|
||||||
* @retval 0 OK
|
* @retval 0 OK
|
||||||
* @retval -1 Error
|
* @retval -1 Error
|
||||||
* @see clixon_err_netconf_fn For variant with netconf error message
|
* @see clixon_netconf_error For variant with netconf error message
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clixon_err_fn(clixon_handle h,
|
clixon_err_fn(clixon_handle h,
|
||||||
|
|
|
||||||
|
|
@ -492,6 +492,7 @@ api_path_fmt_subst_list_key(cbuf *cb,
|
||||||
* api_path: /interfaces/interface=e/ipv4/address=1.2.3.4
|
* api_path: /interfaces/interface=e/ipv4/address=1.2.3.4
|
||||||
* @param[in] api_path_fmt XML key format, eg /aaa/%s/name
|
* @param[in] api_path_fmt XML key format, eg /aaa/%s/name
|
||||||
* @param[in] cvv cligen variable vector, one for every wildchar in api_path_fmt
|
* @param[in] cvv cligen variable vector, one for every wildchar in api_path_fmt
|
||||||
|
* @param[in] yspec
|
||||||
* @param[out] api_path api_path, eg /aaa/17. Free after use
|
* @param[out] api_path api_path, eg /aaa/17. Free after use
|
||||||
* @param[out] cvv_i 1..cvv-len. Index into cvv of last cvv entry used, For example,
|
* @param[out] cvv_i 1..cvv-len. Index into cvv of last cvv entry used, For example,
|
||||||
* if same as len of cvv, all were used, if < some entries were not
|
* if same as len of cvv, all were used, if < some entries were not
|
||||||
|
|
|
||||||
|
|
@ -407,8 +407,8 @@ clixon_msg_send(int s,
|
||||||
clixon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
|
clixon_debug(CLIXON_DBG_MSG, "Send: %s", cbuf_get(cb));
|
||||||
if (atomicio((ssize_t (*)(int, void *, size_t))write,
|
if (atomicio((ssize_t (*)(int, void *, size_t))write,
|
||||||
s, cbuf_get(cb), cbuf_len(cb)) < 0){
|
s, cbuf_get(cb), cbuf_len(cb)) < 0){
|
||||||
clicon_err(OE_CFG, errno, "atomicio");
|
clixon_err(OE_CFG, errno, "atomicio");
|
||||||
clicon_log(LOG_WARNING, "%s: write: %s", __FUNCTION__, strerror(errno));
|
clixon_log(NULL, LOG_WARNING, "%s: write: %s", __FUNCTION__, strerror(errno));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
@ -613,7 +613,7 @@ clixon_msg_rcv11(int s,
|
||||||
struct sigaction oldsigaction[32] = {{{0,},},};
|
struct sigaction oldsigaction[32] = {{{0,},},};
|
||||||
|
|
||||||
if ((cbmsg = cbuf_new()) == NULL){
|
if ((cbmsg = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_XML, errno, "cbuf_new");
|
clixon_err(OE_XML, errno, "cbuf_new");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
eom = 0;
|
eom = 0;
|
||||||
|
|
@ -707,7 +707,7 @@ clicon_rpc(int sock,
|
||||||
goto ok;
|
goto ok;
|
||||||
if (cbrcv){
|
if (cbrcv){
|
||||||
if ((*ret = strdup(cbuf_get(cbrcv))) == NULL){
|
if ((*ret = strdup(cbuf_get(cbrcv))) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "strdup");
|
clixon_err(OE_UNIX, errno, "strdup");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
cbuf_free(cbrcv);
|
cbuf_free(cbrcv);
|
||||||
|
|
@ -740,11 +740,11 @@ send_msg_reply(int s,
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
|
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (cbuf_append_buf(cb, data, datalen) < 0){
|
if (cbuf_append_buf(cb, data, datalen) < 0){
|
||||||
clicon_err(OE_UNIX, errno, "cbuf_append_buf");
|
clixon_err(OE_UNIX, errno, "cbuf_append_buf");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (clixon_msg_send11(s, descr, cb) < 0)
|
if (clixon_msg_send11(s, descr, cb) < 0)
|
||||||
|
|
@ -774,7 +774,7 @@ send_msg_notify(int s,
|
||||||
cbuf *cb = NULL;
|
cbuf *cb = NULL;
|
||||||
|
|
||||||
if ((cb = cbuf_new()) == NULL){
|
if ((cb = cbuf_new()) == NULL){
|
||||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
clixon_err(OE_UNIX, errno, "cbuf_new");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
cprintf(cb, "%s", msg);
|
cprintf(cb, "%s", msg);
|
||||||
|
|
|
||||||
|
|
@ -333,27 +333,31 @@ xpath_optimize_check(xpath_tree *xs,
|
||||||
int *xlen0)
|
int *xlen0)
|
||||||
{
|
{
|
||||||
#ifdef XPATH_LIST_OPTIMIZE
|
#ifdef XPATH_LIST_OPTIMIZE
|
||||||
|
int retval = -1;
|
||||||
int ret;
|
int ret;
|
||||||
clixon_xvec *xvec = NULL;
|
clixon_xvec *xvec = NULL;
|
||||||
|
|
||||||
if (!_optimize_enable)
|
if (!_optimize_enable)
|
||||||
return 0; /* use regular code */
|
goto ok;
|
||||||
if ((xvec = clixon_xvec_new()) == NULL)
|
else if ((xvec = clixon_xvec_new()) == NULL)
|
||||||
return -1;
|
goto done;
|
||||||
/* Glue code since xpath code uses (old) cxobj ** and search code uses (new) clixon_xvec */
|
/* Glue code since xpath code uses (old) cxobj ** and search code uses (new) clixon_xvec */
|
||||||
if ((ret = xpath_list_optimize_fn(xs, xv, xvec)) < 0)
|
else if ((ret = xpath_list_optimize_fn(xs, xv, xvec)) < 0)
|
||||||
return -1;
|
goto done;
|
||||||
if (ret == 1){
|
else if (ret == 1){
|
||||||
if (clixon_xvec_extract(xvec, xvec0, xlen0, NULL) < 0)
|
if (clixon_xvec_extract(xvec, xvec0, xlen0, NULL) < 0){
|
||||||
return -1;
|
goto done;
|
||||||
clixon_xvec_free(xvec);
|
}
|
||||||
_optimize_hits++;
|
_optimize_hits++;
|
||||||
return 1; /* Optimized */
|
retval = 1; /* Optimized */
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
ok:
|
||||||
|
retval = 0; /* use regular code */
|
||||||
|
done:
|
||||||
|
if (xvec)
|
||||||
clixon_xvec_free(xvec);
|
clixon_xvec_free(xvec);
|
||||||
return 0; /* use regular code */
|
return retval;
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return 0; /* use regular code */
|
return 0; /* use regular code */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue