[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] poke: Fix the crash on partial valid dot commands
From: |
Mohammad-Reza Nabipoor |
Subject: |
[COMMITTED] poke: Fix the crash on partial valid dot commands |
Date: |
Fri, 3 Dec 2021 21:55:26 +0330 |
With this commit, commands like `.set ob` does not crash anymore.
2021-12-03 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poke/pk-cmd.c (pk_cmd_exec_1): Update `cmd_name` after finding
the sub-command.
* testsuite/poke.cmd/set-obase-6.pk: New test.
* testsuite/Makefile.am (EXTRA_DIST): Update.
---
ChangeLog | 7 +++++++
poke/pk-cmd.c | 1 +
testsuite/Makefile.am | 1 +
testsuite/poke.cmd/set-obase-6.pk | 5 +++++
4 files changed, 14 insertions(+)
create mode 100644 testsuite/poke.cmd/set-obase-6.pk
diff --git a/ChangeLog b/ChangeLog
index 2a2e11e4..a40d8be3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-12-03 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * poke/pk-cmd.c (pk_cmd_exec_1): Update `cmd_name` after finding
+ the sub-command.
+ * testsuite/poke.cmd/set-obase-6.pk: New test.
+ * testsuite/Makefile.am (EXTRA_DIST): Update.
+
2021-12-03 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* poke/pk-cmd.c (pk_cmd_exec_1): Introduce a new predicate
diff --git a/poke/pk-cmd.c b/poke/pk-cmd.c
index 3c2c6109..eb3706af 100644
--- a/poke/pk-cmd.c
+++ b/poke/pk-cmd.c
@@ -315,6 +315,7 @@ pk_cmd_exec_1 (const char *str, struct pk_trie *cmds_trie,
char *prefix)
pk_printf (_("%s: command not found.\n"), cmd_name);
return 0;
}
+ strncpy (cmd_name, cmd->name, MAX_CMD_NAME - 1);
/* argv[0] is the command name. */
argv[argc].type = PK_CMD_ARG_STR;
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 4a890233..aadbbddd 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -105,6 +105,7 @@ EXTRA_DIST = \
poke.cmd/set-obase-3.pk \
poke.cmd/set-obase-4.pk \
poke.cmd/set-obase-5.pk \
+ poke.cmd/set-obase-6.pk \
poke.cmd/set-odepth-1.pk \
poke.cmd/set-odepth-2.pk \
poke.cmd/set-oindent.pk \
diff --git a/testsuite/poke.cmd/set-obase-6.pk
b/testsuite/poke.cmd/set-obase-6.pk
new file mode 100644
index 00000000..1d6277ad
--- /dev/null
+++ b/testsuite/poke.cmd/set-obase-6.pk
@@ -0,0 +1,5 @@
+/* { dg-do run } */
+
+/* { dg-command { .set ob 2 } } */
+/* { dg-command { 16 } } */
+/* { dg-output "0b00000000000000000000000000010000" } */
--
2.34.1
- [COMMITTED] poke: Fix the crash on partial valid dot commands,
Mohammad-Reza Nabipoor <=