[ovs-dev] [PATCH v3 13/18] datapath: Use proper buffer size in nla_memcpy

Jarno Rajahalme jarno at ovn.org
Sat Jun 18 01:44:26 UTC 2016


From: Haishuang Yan <yanhaishuang at cmss.chinamobile.com>

Upstream commit:
    commit ac71b46efd2838c02ec193987c8f61c3ba33b495
    Author: Haishuang Yan <yanhaishuang at cmss.chinamobile.com>
    Date:   Mon Mar 28 18:08:59 2016 +0800

    openvswitch: Use proper buffer size in nla_memcpy

    For the input parameter count, it's better to use the size
    of destination buffer size, as nla_memcpy would take into
    account the length of the source netlink attribute when
    a data is copied from an attribute.

    Signed-off-by: Haishuang Yan <yanhaishuang at cmss.chinamobile.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    Signed-off-by: Jarno Rajahalme <jarno at ovn.org>

Fixes: c5f6c06b58d6 ("datapath: Interface with NAT.")
Signed-off-by: Jarno Rajahalme <jarno at ovn.org>
---
 datapath/conntrack.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/datapath/conntrack.c b/datapath/conntrack.c
index c476533..ef03026 100644
--- a/datapath/conntrack.c
+++ b/datapath/conntrack.c
@@ -1014,7 +1014,8 @@ static int parse_nat(const struct nlattr *attr,
 			break;
 
 		case OVS_NAT_ATTR_IP_MIN:
-			nla_memcpy(&info->range.min_addr, a, nla_len(a));
+			nla_memcpy(&info->range.min_addr, a,
+				   sizeof(info->range.min_addr));
 			info->range.flags |= NF_NAT_RANGE_MAP_IPS;
 			break;
 
-- 
2.1.4




More information about the dev mailing list