From 4257999df549e9ce8aaea16c4562d85103410f47 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sun, 6 May 2018 21:06:52 +0200 Subject: [PATCH] Fixed JSON unbalanced braces resultin assert --- CHANGELOG.md | 6 +++++- README.md | 2 +- lib/src/clixon_err.c | 11 ++++++----- lib/src/clixon_json.c | 3 ++- lib/src/clixon_json_parse.y | 12 ++++++++---- lib/src/clixon_log.c | 15 +++++++-------- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 665392fd..bc1f43d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ # Clixon Changelog ## 3.7.0 (Upcoming) - +### Major changes: +### Minor changes: +### Corrected Bugs +- Fixed JSON unbalanced braces resultin assert. + ## 3.6.0 (30 April 2018) ### Major changes: diff --git a/README.md b/README.md index 44198776..7b3a05e5 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Background ========== Clixon was implemented to provide an open-source generic configuration -tool. The existing [CLIgen](http://www.cligen.se) tool was for command-lines only, whilke clixon is a system with config-db, xml and rest interfaces. Most of the projects using clixon are for embedded network and measuring devices. But Clixon is more generic than that. +tool. The existing [CLIgen](http://www.cligen.se) tool was for command-lines only, while clixon is a system with configuration database, xml and rest interfaces. Most of the projects using clixon are for embedded network and measuring devices. But Clixon is more generic than that. Users of clixon currently include: * [Netgate](https://www.netgate.com) diff --git a/lib/src/clixon_err.c b/lib/src/clixon_err.c index c50148e0..b6f9069d 100644 --- a/lib/src/clixon_err.c +++ b/lib/src/clixon_err.c @@ -102,7 +102,8 @@ static struct errvec EV[] = { }; static char * -clicon_strerror1(int err, struct errvec vec[]) +clicon_strerror1(int err, + struct errvec vec[]) { struct errvec *ev; @@ -142,10 +143,10 @@ clicon_err_reset(void) */ int clicon_err_fn(const char *fn, - const int line, - int category, - int suberr, - char *reason, ...) + const int line, + int category, + int suberr, + char *reason, ...) { va_list args; int len; diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index b14592cc..d498a202 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -792,7 +792,8 @@ usage(char *argv0) } int -main(int argc, char **argv) +main(int argc, + char **argv) { cxobj *xt; cxobj *xc; diff --git a/lib/src/clixon_json_parse.y b/lib/src/clixon_json_parse.y index 55fb5f5a..1cf6a583 100644 --- a/lib/src/clixon_json_parse.y +++ b/lib/src/clixon_json_parse.y @@ -101,7 +101,7 @@ object. /* typecast macro */ #define _JY ((struct clicon_json_yacc_arg *)_jy) -#define _YYERROR(msg) {clicon_debug(2, "YYERROR %s '%s' %d", (msg), clixon_json_parsetext, _JY->jy_linenum); YYERROR;} +#define _YYERROR(msg) {clicon_err(OE_XML, 0, "YYERROR %s '%s' %d", (msg), clixon_json_parsetext, _JY->jy_linenum); YYERROR;} /* add _yy to error paramaters */ #define YY_(msgid) msgid @@ -139,7 +139,8 @@ extern int clixon_json_parseget_lineno (void); */ void -clixon_json_parseerror(void *_jy, char *s) +clixon_json_parseerror(void *_jy, + char *s) { clicon_err(OE_XML, 0, "%s on line %d: %s at or before: '%s'", _JY->jy_name, @@ -192,7 +193,10 @@ json_current_clone(struct clicon_json_yacc_arg *jy) { cxobj *xn; - assert(xn = jy->jy_current); + if (jy->jy_current == NULL){ + return -1; + } + xn = jy->jy_current; json_current_pop(jy); if (jy->jy_current) json_current_new(jy, xml_name(xn)); @@ -258,7 +262,7 @@ array : '[' ']' ; valuelist : value - | valuelist { json_current_clone(_JY);} ',' value + | valuelist { if (json_current_clone(_JY)< 0) _YYERROR("stack?");} ',' value ; /* quoted string */ diff --git a/lib/src/clixon_log.c b/lib/src/clixon_log.c index e55bcba0..21d24bcc 100644 --- a/lib/src/clixon_log.c +++ b/lib/src/clixon_log.c @@ -157,13 +157,12 @@ slogtime(void) /*! Make a logging call to syslog (or stderr). - * - * This is the _only_ place the actual syslog (or stderr) logging is made in clicon,.. - * @note syslog makes itw own filtering, but if log to stderr we do it here - * @see clicon_debug() * * @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG. Thisis OR:d with facility == LOG_USER * @param[in] msg Message to print as argv. + * This is the _only_ place the actual syslog (or stderr) logging is made in clicon,.. + * @note syslog makes itw own filtering, but if log to stderr we do it here + * @see clicon_debug */ int clicon_log_str(int level, @@ -214,13 +213,13 @@ clicon_log_str(int level, /*! Make a logging call to syslog using variable arg syntax. * - * See also clicon_log_init() and clicon_log_str() - * + * @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG. This + * is OR:d with facility == LOG_USER + * @param[in] format Message to print as argv. * @code clicon_log(LOG_NOTICE, "%s: dump to dtd not supported", __PROGRAM__); * @endcode - * @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG. Thisis OR:d with facility == LOG_USER - * @param[in] format Message to print as argv. + * @see cicon_log_init and clicon_log_str */ int clicon_log(int level,