From: Michael Tremer Date: Tue, 13 Jun 2017 18:26:08 +0000 (+0100) Subject: ports: Don't crash with an assertion error when no hook can be found X-Git-Tag: 009~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c949dd59a783c432d10b19dce7aa1aa0a5b3ffa;p=network.git ports: Don't crash with an assertion error when no hook can be found This happens when a device has an empty configuration file or the HOOK variable is not set for an other reason. In that case the function make the entire program crash. This patch changes behaviour in that sense that the function returns with an error which must be evaluated by the calling function. Fixes #11400 Reported-by: Daniel Weismüller Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.ports b/src/functions/functions.ports index 40f4eaea..952eef9b 100644 --- a/src/functions/functions.ports +++ b/src/functions/functions.ports @@ -256,7 +256,11 @@ port_cmd() { local hook=$(port_get_hook ${port}) - assert isset hook + # Abort if we could not find a hook + if ! isset hook; then + log CRITICAL "Port ${port} does not have a hook associated with it" + return ${EXIT_ERROR} + fi hook_exec port ${hook} ${cmd} ${port} $@ }