All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ebtablesd: Fix missing arguments for %s in error messages
@ 2026-11-25  9:04 YuPeng
  2026-11-25 11:00 ` Phil Sutter
  0 siblings, 1 reply; 2+ messages in thread
From: YuPeng @ 2026-11-25  9:04 UTC (permalink / raw)
  To: netfilter-devel; +Cc: fw, phil, debianyu

Five ebt_print_error() calls in ebtablesd.c use a "%s" format
specifier without passing the corresponding argument.  As
__ebt_print_error() is variadic, this is undefined behaviour and what
gets printed depends on leftover register contents.  With current gcc
output on x86-64 the preceding strcmp() happens to leave argv[2] in
the variadic argument register, so the message usually still names the
table; different code generation or a different call site can print
garbage, print "(null)", or crash instead of reporting the error.

Pass argv[2], which holds the table name for the free, open, fopen,
commit and fcommit commands, as the calls just around these already do.

This fix was originally carried in the Kylin Linux SRPM since 2022;
the commit message has been rewritten to describe the behaviour
observed on current master.

Signed-off-by: YuPeng <yupeng@kylinos.cn>
---
 ebtablesd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ebtablesd.c b/ebtablesd.c
index 02d51fa..930fc66 100644
--- a/ebtablesd.c
+++ b/ebtablesd.c
@@ -194,7 +194,7 @@ continue_read:
 			}
 			if (!(replace[i].flags & OPT_KERNELDATA)) {
 				ebt_print_error("ebtablesd: table %s has not "
-				                "been opened");
+				                "been opened", argv[2]);
 				goto write_msg;
 			}
 			ebt_cleanup_replace(&replace[i]);
@@ -219,7 +219,7 @@ continue_read:
 			if (replace[i].flags & OPT_KERNELDATA) {
 				ebt_print_error("ebtablesd: table %s needs to "
 				                "be freed before it can be "
-				                "opened");
+				                "opened", argv[2]);
 				goto write_msg;
 			}
 			if (!ebt_get_kernel_table(&replace[i], 0)) {
@@ -248,7 +248,7 @@ continue_read:
 			if (replace[i].flags & OPT_KERNELDATA) {
 				ebt_print_error("ebtablesd: table %s needs to "
 				                "be freed before it can be "
-				                "opened");
+				                "opened", argv[2]);
 				goto write_msg;
 			}
 			tmp.filename = (char *)malloc(strlen(argv[3]) + 1);
@@ -296,7 +296,7 @@ continue_read:
 			}
 			if (!(replace[i].flags & OPT_KERNELDATA)) {
 				ebt_print_error("ebtablesd: table %s has not "
-				                "been opened");
+				                "been opened", argv[2]);
 				goto write_msg;
 			}
 			/* The counters from the kernel are useless if we 
@@ -324,7 +324,7 @@ continue_read:
 			}
 			if (!(replace[i].flags & OPT_KERNELDATA)) {
 				ebt_print_error("ebtablesd: table %s has not "
-				                "been opened");
+				                "been opened", argv[2]);
 				goto write_msg;
 			}
 			replace[i].filename = (char *)malloc(strlen(argv[3]) + 1);
-- 
2.39.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:04 [PATCH] ebtablesd: Fix missing arguments for %s in error messages YuPeng
2026-11-25 11:00 ` Phil Sutter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.