- Memleaks in xpath parse error
- Static linkage cli fix (worked in 5.3.0 but restructuring broke it) - Renamed all cligen_ph_active_get to cligen_pt_active_get - Added AFL deferred init - test_install.sh for static .a suffix
This commit is contained in:
parent
d175720b7e
commit
42e61f461c
11 changed files with 59 additions and 41 deletions
|
|
@ -51,8 +51,9 @@ SH_SUFFIX = @SH_SUFFIX@
|
||||||
LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@
|
LIBSTATIC_SUFFIX = @LIBSTATIC_SUFFIX@
|
||||||
INSTALLFLAGS = @INSTALLFLAGS@
|
INSTALLFLAGS = @INSTALLFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
ifeq ($(LINKAGE),dynamic)
|
ifneq ($(LINKAGE),dynamic)
|
||||||
LDFLAGS += -rdynamic -L. # -rdynamic for using -ldl
|
# -rdynamic for using -ldl
|
||||||
|
LDFLAGS += -rdynamic
|
||||||
endif
|
endif
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
|
|
@ -179,13 +180,19 @@ test: $(MYLIBSTATIC)
|
||||||
endif
|
endif
|
||||||
$(CC) $(INCLUDES) $(LDFLAGS) -L . $^ $(LIBS) -o $@
|
$(CC) $(INCLUDES) $(LDFLAGS) -L . $^ $(LIBS) -o $@
|
||||||
|
|
||||||
|
# Note1: static linking of clixon_cli must have:
|
||||||
|
# 1) -rdynamic
|
||||||
|
# 2) $(APPOBJ)
|
||||||
|
# Note2: LIBDEPS is just a mechanism to ensure libclixon.so is built
|
||||||
|
$(APPL): $(APPOBJ) $(LIBDEPS)
|
||||||
ifeq ($(LINKAGE),dynamic)
|
ifeq ($(LINKAGE),dynamic)
|
||||||
$(APPL): $(MYLIBDYNAMIC)
|
$(APPL): $(MYLIBDYNAMIC)
|
||||||
|
echo "LIBS:$(LIBS)"
|
||||||
|
$(CC) $(LDFLAGS) $(APPOBJ) $(EXTRAS) $(CLIGEN_LIB) $(LIBS) -L. $< -o $@
|
||||||
else
|
else
|
||||||
$(APPL): $(MYLIBSTATIC)
|
$(APPL): $(LIBOBJ)
|
||||||
|
$(CC) $(LDFLAGS) $(APPOBJ) $(EXTRAS) $(LIBOBJ) $(CLIGEN_LIB) $(LIBS) -o $@
|
||||||
endif
|
endif
|
||||||
$(APPL): $(APPOBJ) $(LIBDEPS)
|
|
||||||
$(CC) $(LDFLAGS) $(EXTRAS) -L. $^ $(CLIGEN_LIB) $(LIBS) -o $@
|
|
||||||
|
|
||||||
$(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS)
|
$(MYLIBDYNAMIC) : $(LIBOBJ) $(LIBDEPS)
|
||||||
ifeq ($(HOST_VENDOR),apple)
|
ifeq ($(HOST_VENDOR),apple)
|
||||||
|
|
|
||||||
|
|
@ -1310,7 +1310,7 @@ cli_help(clicon_handle h, cvec *vars, cvec *argv)
|
||||||
cligen_handle ch = cli_cligen(h);
|
cligen_handle ch = cli_cligen(h);
|
||||||
parse_tree *pt;
|
parse_tree *pt;
|
||||||
|
|
||||||
pt = cligen_ph_active_get(ch);
|
pt = cligen_pt_active_get(ch);
|
||||||
return cligen_help(ch, stdout, pt);
|
return cligen_help(ch, stdout, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -575,6 +575,10 @@ main(int argc,
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
|
#ifdef __AFL_HAVE_MANUAL_CONTROL
|
||||||
|
__AFL_INIT();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Access the remaining argv/argc options (after --) w clicon-argv_get() */
|
/* Access the remaining argv/argc options (after --) w clicon-argv_get() */
|
||||||
clicon_argv_set(h, argv0, argc, argv);
|
clicon_argv_set(h, argv0, argc, argv);
|
||||||
|
|
||||||
|
|
@ -754,8 +758,9 @@ main(int argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go into event-loop unless -1 command-line */
|
/* Go into event-loop unless -1 command-line */
|
||||||
if (!once)
|
if (!once){
|
||||||
retval = cli_interactive(h);
|
retval = cli_interactive(h);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
retval = 0;
|
retval = 0;
|
||||||
done:
|
done:
|
||||||
|
|
|
||||||
|
|
@ -523,8 +523,10 @@ cli_handler_err(FILE *f)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Evaluate a matched command
|
/*! Evaluate a matched command
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] cmd The command string
|
* @param[in] cmd The command string
|
||||||
|
* @param[in] match_obj
|
||||||
|
* @param[in] cvv
|
||||||
* @retval int If there is a callback, the return value of the callback is returned,
|
* @retval int If there is a callback, the return value of the callback is returned,
|
||||||
* @retval 0 otherwise
|
* @retval 0 otherwise
|
||||||
*/
|
*/
|
||||||
|
|
@ -603,13 +605,13 @@ clicon_parse(clicon_handle h,
|
||||||
}
|
}
|
||||||
if (csm != NULL){
|
if (csm != NULL){
|
||||||
modename0 = NULL;
|
modename0 = NULL;
|
||||||
if ((pt = cligen_ph_active_get(cli_cligen(h))) != NULL)
|
if ((pt = cligen_pt_active_get(cli_cligen(h))) != NULL)
|
||||||
modename0 = pt_name_get(pt);
|
modename0 = pt_name_get(pt);
|
||||||
if (cligen_ph_active_set(cli_cligen(h), modename) < 0){
|
if (cligen_ph_active_set(cli_cligen(h), modename) < 0){
|
||||||
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((pt = cligen_ph_active_get(cli_cligen(h))) == NULL){
|
if ((pt = cligen_pt_active_get(cli_cligen(h))) == NULL){
|
||||||
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
fprintf(stderr, "No such parse-tree registered: %s\n", modename);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -876,6 +876,10 @@ main(int argc,
|
||||||
if (send_hello(h, 1, id) < 0)
|
if (send_hello(h, 1, id) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
#ifdef __AFL_HAVE_MANUAL_CONTROL
|
||||||
|
/* American fuzzy loop deferred init, see CLICON_NETCONF_HELLO_OPTIONAL=true, see a speedup of x10 */
|
||||||
|
__AFL_INIT();
|
||||||
|
#endif
|
||||||
if (clixon_event_reg_fd(0, netconf_input_cb, h, "netconf socket") < 0)
|
if (clixon_event_reg_fd(0, netconf_input_cb, h, "netconf socket") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
if (dbg)
|
if (dbg)
|
||||||
|
|
@ -887,6 +891,7 @@ main(int argc,
|
||||||
if (clixon_event_reg_timeout(t, timeout_fn, NULL, "timeout") < 0)
|
if (clixon_event_reg_timeout(t, timeout_fn, NULL, "timeout") < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clixon_event_loop(h) < 0)
|
if (clixon_event_loop(h) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,9 @@ $(RESTCONF_PLUGIN): $(RESTCONF_OBJ)
|
||||||
ifeq ($(LINKAGE),dynamic)
|
ifeq ($(LINKAGE),dynamic)
|
||||||
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $^ -lclixon -lclixon_restconf
|
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $^ -lclixon -lclixon_restconf
|
||||||
else
|
else
|
||||||
# XXX need to add -L ../../apps/restconf otherwise get undefined:
|
# Linkage -static:
|
||||||
# plugin_load_one file:/usr/local/lib/example/restconf/example_restconf.so function:clixon_plugin_init
|
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $^ -lclixon -L ../../apps/restconf/ -lclixon_restconf
|
||||||
# plugin_load_one: 338: Plugins: dlopen(/usr/local/lib/example/restconf/example_restconf.so): /usr/local/lib/libclixon_restconf.so.5: undefined symbol: api_return_err
|
# $(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $^ -lclixon -lclixon_restconf
|
||||||
$(CC) -Wall -shared $(LDFLAGS) -o $@ -lc $^ -lclixon -L ../../apps/restconf/ -lclixon_restconf
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SRC = $(BE_SRC) $(BE2_SRC) $(CLI_SRC) $(NETCONF_SRC)
|
SRC = $(BE_SRC) $(BE2_SRC) $(CLI_SRC) $(NETCONF_SRC)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
This dir contains code for fuzzing clixon cli.
|
This dir contains code for fuzzing clixon cli.
|
||||||
|
|
||||||
Note: cli plugins do not work.
|
|
||||||
|
|
||||||
## Prereqs
|
## Prereqs
|
||||||
|
|
||||||
Install AFL, see [..](..)
|
Install AFL, see [..](..)
|
||||||
|
|
@ -12,7 +10,7 @@ Build and install a clixon system (in particular the backend, the CLI will be re
|
||||||
|
|
||||||
Build and install CLIgen statically:
|
Build and install CLIgen statically:
|
||||||
```
|
```
|
||||||
CC=/usr/bin/afl-clang-fast LINKAGE=static INSTALLFLAGS="" ./configure
|
./configure LINKAGE=static INSTALLFLAGS="" CC=/usr/bin/afl-clang-fast
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
|
||||||
|
|
@ -384,31 +384,31 @@ start : expr X_EOF { _XPY->xpy_top=$1;_PARSE_DEBUG("start->expr");
|
||||||
| locationpath X_EOF { _XPY->xpy_top=$1;_PARSE_DEBUG("start->locationpath"); YYACCEPT; }
|
| locationpath X_EOF { _XPY->xpy_top=$1;_PARSE_DEBUG("start->locationpath"); YYACCEPT; }
|
||||||
;
|
;
|
||||||
|
|
||||||
expr : expr LOGOP andexpr { $$=xp_new(XP_EXP,$2,NULL,NULL,NULL,$1, $3);_PARSE_DEBUG("expr->expr or andexpr"); }
|
expr : expr LOGOP andexpr { $$=xp_new(XP_EXP,$2,NULL,NULL,NULL,$1, $3);_XPY->xpy_top=$$; _PARSE_DEBUG("expr->expr or andexpr"); }
|
||||||
| andexpr { $$=xp_new(XP_EXP,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("expr-> andexpr"); }
|
| andexpr { $$=xp_new(XP_EXP,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("expr-> andexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
andexpr : andexpr LOGOP relexpr { $$=xp_new(XP_AND,$2,NULL,NULL,NULL,$1, $3);_PARSE_DEBUG("andexpr-> andexpr and relexpr"); }
|
andexpr : andexpr LOGOP relexpr { $$=xp_new(XP_AND,$2,NULL,NULL,NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("andexpr-> andexpr and relexpr"); }
|
||||||
| relexpr { $$=xp_new(XP_AND,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("andexpr-> relexpr"); }
|
| relexpr { $$=xp_new(XP_AND,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("andexpr-> relexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
relexpr : relexpr RELOP addexpr { $$=xp_new(XP_RELEX,$2,NULL,NULL,NULL,$1, $3);_PARSE_DEBUG("relexpr-> relexpr relop addexpr"); }
|
relexpr : relexpr RELOP addexpr { $$=xp_new(XP_RELEX,$2,NULL,NULL,NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("relexpr-> relexpr relop addexpr"); }
|
||||||
| addexpr { $$=xp_new(XP_RELEX,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("relexpr-> addexpr"); }
|
| addexpr { $$=xp_new(XP_RELEX,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("relexpr-> addexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
addexpr : addexpr ADDOP unionexpr { $$=xp_new(XP_ADD,$2,NULL,NULL,NULL,$1, $3);_PARSE_DEBUG("addexpr-> addexpr ADDOP unionexpr"); }
|
addexpr : addexpr ADDOP unionexpr { $$=xp_new(XP_ADD,$2,NULL,NULL,NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("addexpr-> addexpr ADDOP unionexpr"); }
|
||||||
| unionexpr { $$=xp_new(XP_ADD,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("addexpr-> unionexpr"); }
|
| unionexpr { $$=xp_new(XP_ADD,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("addexpr-> unionexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* node-set */
|
/* node-set */
|
||||||
unionexpr : unionexpr '|' pathexpr { $$=xp_new(XP_UNION,XO_UNION,NULL,NULL,NULL,$1, $3);_PARSE_DEBUG("unionexpr-> unionexpr | pathexpr"); }
|
unionexpr : unionexpr '|' pathexpr { $$=xp_new(XP_UNION,XO_UNION,NULL,NULL,NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("unionexpr-> unionexpr | pathexpr"); }
|
||||||
| pathexpr { $$=xp_new(XP_UNION,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("unionexpr-> pathexpr"); }
|
| pathexpr { $$=xp_new(XP_UNION,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("unionexpr-> pathexpr"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
pathexpr : locationpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("pathexpr-> locationpath"); }
|
pathexpr : locationpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("pathexpr-> locationpath"); }
|
||||||
| filterexpr { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("pathexpr-> filterexpr"); }
|
| filterexpr { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_XPY->xpy_top=$$;_PARSE_DEBUG("pathexpr-> filterexpr"); }
|
||||||
| filterexpr '/' rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("/"),NULL,$1, $3);_PARSE_DEBUG("pathexpr-> filterexpr / rellocpath"); }
|
| filterexpr '/' rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("/"),NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("pathexpr-> filterexpr / rellocpath"); }
|
||||||
| filterexpr DOUBLESLASH rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("//"),NULL,$1, $3);_PARSE_DEBUG("pathexpr-> filterexpr // rellocpath"); }
|
| filterexpr DOUBLESLASH rellocpath { $$=xp_new(XP_PATHEXPR,A_NAN,NULL,strdup("//"),NULL,$1, $3);_XPY->xpy_top=$$;_PARSE_DEBUG("pathexpr-> filterexpr // rellocpath"); }
|
||||||
;
|
;
|
||||||
|
|
||||||
filterexpr : primaryexpr { $$=xp_new(XP_FILTEREXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("filterexpr-> primaryexpr"); }
|
filterexpr : primaryexpr { $$=xp_new(XP_FILTEREXPR,A_NAN,NULL,NULL,NULL,$1, NULL);_PARSE_DEBUG("filterexpr-> primaryexpr"); }
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ TOKEN=$1
|
||||||
# Configure (clixon)
|
# Configure (clixon)
|
||||||
#CFLAGS="-g -Wall" INSTALLFLAGS="" ./configure
|
#CFLAGS="-g -Wall" INSTALLFLAGS="" ./configure
|
||||||
#sudo ldconfig
|
#sudo ldconfig
|
||||||
LDFLAGS=-coverage LINKAGE=static CFLAGS="-g -Wall -coverage" INSTALLFLAGS="" ./configure
|
./configure LDFLAGS=-coverage LINKAGE=static CFLAGS="-g -Wall -coverage" INSTALLFLAGS=""
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
make clean
|
make clean
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,4 @@ CERTKEYLEN=2048
|
||||||
# Linking: static or dynamic
|
# Linking: static or dynamic
|
||||||
LINKAGE=@LINKAGE@
|
LINKAGE=@LINKAGE@
|
||||||
SH_SUFFIX=@SH_SUFFIX@
|
SH_SUFFIX=@SH_SUFFIX@
|
||||||
|
LIBSTATIC_SUFFIX=@LIBSTATIC_SUFFIX@
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,10 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
# Check for soft links for .so files in case of dynamic linkage, but .a files f static linking
|
# Check for soft links for .so files in case of dynamic linkage, but .a files f static linking
|
||||||
if [ ${LINKAGE} = static ]; then
|
if [ ${LINKAGE} = static ]; then
|
||||||
LIBOPT=-f
|
LIBOPT=-f
|
||||||
|
SUFFIX=${LIBSTATIC_SUFFIX}
|
||||||
else
|
else
|
||||||
LIBOPT=-h
|
LIBOPT=-h
|
||||||
|
SUFFIX=${SH_SUFFIX}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
new "Set up installdir $dir"
|
new "Set up installdir $dir"
|
||||||
|
|
@ -32,18 +34,18 @@ new "Check installed files clixon-config"
|
||||||
if [ ! -f $dir/usr/local/share/clixon/clixon-config* ]; then
|
if [ ! -f $dir/usr/local/share/clixon/clixon-config* ]; then
|
||||||
err $dir/usr/local/share/clixon/clixon-config*
|
err $dir/usr/local/share/clixon/clixon-config*
|
||||||
fi
|
fi
|
||||||
new "Check installed files libclixon${SH_SUFFIX}"
|
new "Check installed files libclixon${SUFFIX}"
|
||||||
# Check both /usr/local/lib and /usr/lib
|
# Check both /usr/local/lib and /usr/lib
|
||||||
# This is a problem on some platforms that dont have /usr/local/ in LD_LIBRARY_PATH
|
# This is a problem on some platforms that dont have /usr/local/ in LD_LIBRARY_PATH
|
||||||
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon${SH_SUFFIX} ]; then
|
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon${SUFFIX} ]; then
|
||||||
if [ ! ${LIBOPT} $dir/usr/lib/libclixon${SH_SUFFIX} ]; then
|
if [ ! ${LIBOPT} $dir/usr/lib/libclixon${SUFFIX} ]; then
|
||||||
err $dir/usr/local/lib/libclixon${SH_SUFFIX}
|
err $dir/usr/local/lib/libclixon${SUFFIX}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
new "Check installed files libclixon_backend${SH_SUFFIX}"
|
new "Check installed files libclixon_backend${SUFFIX}"
|
||||||
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon_backend${SH_SUFFIX} ]; then
|
if [ ! ${LIBOPT} $dir/usr/local/lib/libclixon_backend${SUFFIX} ]; then
|
||||||
if [ ! ${LIBOPT} $dir/usr/lib/libclixon_backend${SH_SUFFIX} ]; then
|
if [ ! ${LIBOPT} $dir/usr/lib/libclixon_backend${SUFFIX} ]; then
|
||||||
err $dir/usr/local/lib/libclixon_backend${SH_SUFFIX}
|
err $dir/usr/local/lib/libclixon_backend${SUFFIX}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue