From 1afd48e840b97f158ece959b80812dd327565b4b Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Wed, 29 Oct 2025 09:32:03 -0400 Subject: [PATCH] Corrected an error in which an invalid client name passed to the "macro" command will crash magic. This will happen if, for example, magic is compiled without OpenGL support, in which case the "wind3d" client does not exist, and parsing the default macros from the system .magicrc file will cause an immediate crash. --- VERSION | 2 +- windows/windCmdAM.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 706dfb24..970db810 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.569 +8.3.570 diff --git a/windows/windCmdAM.c b/windows/windCmdAM.c index 1ec32e78..20edb953 100644 --- a/windows/windCmdAM.c +++ b/windows/windCmdAM.c @@ -1124,13 +1124,17 @@ windDoMacro(w, cmd, interactive) /* next argument looks like a key, which would indicate */ /* an unregistered client as the first argument. A */ /* macro retrieved from an unregistered client returns */ - /* nothing but does not generate an error. */ + /* nothing but does not generate an error. This allows */ + /* the default macro set to declare macros for, e.g., the */ + /* wind3d client and fail quietly if magic was compiled */ + /* without OpenGL support. */ if (MacroKey(cmd->tx_argv[argstart], &verbose) == 0) if (MacroKey(cmd->tx_argv[argstart + 1], &verbose) != 0) { wc = 0; argstart++; + return; } } } @@ -1139,6 +1143,11 @@ windDoMacro(w, cmd, interactive) if (cmd->tx_argc == argstart) { + if (wc == (WindClient)0) + { + TxError("No such client.\n"); + return; + } h = HashLookOnly(&MacroClients, (char *)wc); if (h == NULL) return; @@ -1302,5 +1311,5 @@ windDoMacro(w, cmd, interactive) return; } - TxError("Usage: %s [macro_name [string] [help_text]]\n", cmd->tx_argv[0]); + TxError("Usage: %s [client] [macro_name [string] [help_text]]\n", cmd->tx_argv[0]); }