[ovs-dev] [PATCH] Fixed segfault in learn_format

Jari Sundell sundell.software at gmail.com
Mon Nov 14 09:27:05 UTC 2011


This patch fixes an issue where dst_field->n_bytes == 1 and
src_value_bytes == 2 causing a segfault.

Jari Sundell

---

diff --git a/lib/learn.c b/lib/learn.c
index 9f95a13..9fea40a 100644
--- a/lib/learn.c
+++ b/lib/learn.c
@@ -622,8 +622,10 @@ learn_format(const struct nx_action_learn *learn,
struct ds *s)
                 uint8_t *bytes = (uint8_t *) &value;

                 memset(&value, 0, sizeof value);
-                memcpy(&bytes[dst_field->n_bytes - src_value_bytes],
-                       src_value, src_value_bytes);
+                if (dst_field->n_bytes >= src_value_bytes) {
+                    memcpy(&bytes[dst_field->n_bytes - src_value_bytes],
+                           src_value, src_value_bytes);
+                }
                 ds_put_format(s, "%s=", dst_field->name);
                 mf_format(dst_field, &value, NULL, s);
             } else {



More information about the dev mailing list