OSDN Git Service

libsubcmd: Avoid SEGV/use-after-free when commands aren't excluded
authorIan Rogers <irogers@google.com>
Fri, 7 Jul 2023 23:09:26 +0000 (16:09 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 11 Jul 2023 19:44:12 +0000 (16:44 -0300)
commit4b96679170c63be361d1b0fdeb81bb0ef207dbcb
treecea23fa42d5b416e4f2c000625d36b3b21779d73
parentad07149f34dbb3e0f4e25e19ef80bdd3216ba1cf
libsubcmd: Avoid SEGV/use-after-free when commands aren't excluded

The array shortening may perform unnecessary array copies.

Before commit 657a3efee43a ("lib subcmd: Avoid memory leak in
exclude_cmds") this was benign, but afterwards this could lead to a
SEGV.

Fixes: 657a3efee43a29d1 ("lib subcmd: Avoid memory leak in exclude_cmds")
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Chenyuan Mi <cymi20@fudan.edu.cn>
Cc: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20230707230926.841086-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/subcmd/help.c