The pop action execution in trace may print garbage data due to
uninitialized buffer. For example, when it is supposed to print:

pop(reg2) <- 0x50;

it could print:

pop(reg2) <- 
0xf8a720000000000060f9000000000000306d572fff7f000032fc466a30560000e06d572fff7f0000f831461c5d7f0000506d572fff7f0000fcf2476a305600001800000000000000f831461c5d7f0000906d572fff7f000079fa476a305600000000000000000000e06d572fff7f00001800000000000000f831461c00000050;

The actual value is the at the 0x50 at the tail but it prints the whole
128 byte buffer. This patch fixes it.

Fixes: 8ce847737f2d ("actions: Add stack push and pop actions.")
Signed-off-by: Han Zhou <hz...@ovn.org>
---
 utilities/ovn-trace.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
index 0331eac21abd..08a22e7c2108 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -1621,12 +1621,8 @@ execute_pop(const struct ovnact_push_pop *p, struct 
ofpbuf *stack,
     const void *src = nx_stack_pop(stack, &src_bytes);
     if (src) {
         union mf_subvalue sv;
-        uint8_t dst_bytes = DIV_ROUND_UP(sf.n_bits, 8);
+        memset(&sv, 0, sizeof sv);
 
-        if (src_bytes < dst_bytes) {
-            memset(&sv.u8[sizeof sv - dst_bytes], 0,
-                   dst_bytes - src_bytes);
-        }
         memcpy(&sv.u8[sizeof sv - src_bytes], src, src_bytes);
         mf_write_subfield_flow(&sf, &sv, uflow);
         mf_format_subvalue(&sv, &s);
-- 
2.38.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to