* [nft PATCH v2] evaluate: fix check for unknown in cmd_op_to_name
@ 2024-02-07 12:27 谢致邦 (XIE Zhibang)
2024-02-07 13:09 ` Phil Sutter
0 siblings, 1 reply; 2+ messages in thread
From: 谢致邦 (XIE Zhibang) @ 2024-02-07 12:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: 谢致邦 (XIE Zhibang)
Example:
nft --debug=all destroy table ip missingtable
Before:
Evaluate unknown
After:
Evaluate destroy
Fixes: e1dfd5cc4c46 ("src: add support to command "destroy"")
Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
---
V1 -> V2: Update subject and message
src/evaluate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 68cfd7765381..57da4044e8c0 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -6048,7 +6048,7 @@ static const char * const cmd_op_name[] = {
static const char *cmd_op_to_name(enum cmd_ops op)
{
- if (op > CMD_DESCRIBE)
+ if (op > CMD_DESTROY)
return "unknown";
return cmd_op_name[op];
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [nft PATCH v2] evaluate: fix check for unknown in cmd_op_to_name
2024-02-07 12:27 [nft PATCH v2] evaluate: fix check for unknown in cmd_op_to_name 谢致邦 (XIE Zhibang)
@ 2024-02-07 13:09 ` Phil Sutter
0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2024-02-07 13:09 UTC (permalink / raw)
To: 谢致邦 (XIE Zhibang); +Cc: netfilter-devel
On Wed, Feb 07, 2024 at 12:27:57PM +0000, 谢致邦 (XIE Zhibang) wrote:
> Example:
> nft --debug=all destroy table ip missingtable
>
> Before:
> Evaluate unknown
>
> After:
> Evaluate destroy
>
> Fixes: e1dfd5cc4c46 ("src: add support to command "destroy"")
> Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
> ---
> V1 -> V2: Update subject and message
>
> src/evaluate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/evaluate.c b/src/evaluate.c
> index 68cfd7765381..57da4044e8c0 100644
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -6048,7 +6048,7 @@ static const char * const cmd_op_name[] = {
>
> static const char *cmd_op_to_name(enum cmd_ops op)
> {
> - if (op > CMD_DESCRIBE)
> + if (op > CMD_DESTROY)
> return "unknown";
>
> return cmd_op_name[op];
Maybe eliminate this source of error once and for all by making it:
| if (op >= array_size(cmd_op_name)
We may still return a NULL pointer if there are uninitialized array
elements, but it's used for format strings only so should not harm.
Cheers, Phil
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-07 13:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07 12:27 [nft PATCH v2] evaluate: fix check for unknown in cmd_op_to_name 谢致邦 (XIE Zhibang)
2024-02-07 13:09 ` Phil Sutter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).