Skip to contentSkip to conversation

tests: iptables-test: Fix command segfault reports

PATCH In review Phil Sutter 1 participant 2 messages Aug 10, 2023 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 tests: iptables-test: Fix command segfault reports

Logging produced a stack trace due to undefined variable 'cmd'.

Fixes 0e80cfea3762b ("tests: iptables-test: Implement fast test mode")
---
 iptables-test.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
iptables-test.py +6 -3
index ef0a35d3daa22..6f63cdbeda9af 100755
@@ -136,7 +136,7 @@ STDERR_IS_TTY = sys.stderr.isatty()
     # check for segfaults
     #
     if proc.returncode == -11:
-        reason = "iptables-save segfaults: " + cmd
+        reason = command + " segfaults!"
         print_error(reason, filename, lineno)
         delete_rule(iptables, rule, filename, lineno, netns)
         return -1
@@ -333,8 +333,11 @@ STDERR_IS_TTY = sys.stderr.isatty()
     out, err = proc.communicate(input = restore_data)
 
     if proc.returncode == -11:
-        reason = iptables + "-restore segfaults: " + cmd
+        reason = iptables + "-restore segfaults!"
         print_error(reason, filename, lineno)
+        msg = [iptables + "-restore segfault from:"]
+        msg.extend(["input: " + l for l in restore_data.split("\n")])
+        print("\n".join(msg), file=log_file)
         return -1
 
     if proc.returncode != 0:
@@ -355,7 +358,7 @@ STDERR_IS_TTY = sys.stderr.isatty()
     out, err = proc.communicate()
 
     if proc.returncode == -11:
-        reason = iptables + "-save segfaults: " + cmd
+        reason = iptables + "-save segfaults!"
         print_error(reason, filename, lineno)
         return -1
 
Signature · 1 line
2.40.0
author reviewer
#1 lore raw
Quoted 4 lines · Phil Sutter

Logging produced a stack trace due to undefined variable 'cmd'.

Fixes 0e80cfea3762b ("tests: iptables-test: Implement fast test mode")

Patch applied.