]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Catch commands returning invalid codes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 22 Oct 2022 08:15:33 +0000 (04:15 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 22 Oct 2022 08:15:33 +0000 (04:15 -0400)
src/bin/unit_test_attribute.c

index 1b6a2bbcfe4aef8372ec24bc63f0e777a01f07a7..845e332d4ac857a1ba6642eb42be11d7b36a8e36 100644 (file)
@@ -981,7 +981,7 @@ static int dictionary_load_common(command_result_t *result, command_file_ctx_t *
         *      Decrease ref count if we're loading in a new dictionary
         */
        if (cc->tmpl_rules.attr.dict_def) {
-               if (fr_dict_const_free(&cc->tmpl_rules.attr.dict_def, __FILE__) < 0) return -1;
+               if (fr_dict_const_free(&cc->tmpl_rules.attr.dict_def, __FILE__) < 0) RETURN_COMMAND_ERROR();
        }
 
        q = strchr(in, ' ');
@@ -3497,7 +3497,6 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, command_config_t const
                case RESULT_MISMATCH:
                {
                        ret = EXIT_FAILURE;
-
                        goto finish;
                }
 
@@ -3505,6 +3504,14 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, command_config_t const
                        ret = result.ret;
                        *exit_now = true;
                        goto finish;
+
+               default:
+                       /*
+                        *      If this happens, fix the damn command.
+                        */
+                       fr_assert_msg(false, "Command exited with invalid return code (%i)", result.rcode);
+                       ret = -1;
+                       goto finish;
                }
        }