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.
This commit is contained in:
R. Timothy Edwards
2025-10-29 09:32:03 -04:00
parent 99a5a28a3e
commit 1afd48e840
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
8.3.569
8.3.570
+11 -2
View File
@@ -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]);
}