summaryrefslogtreecommitdiffstats
path: root/lib/route
diff options
context:
space:
mode:
authorNicolas PLANEL <nicolas.planel@enovance.com>2014-08-26 15:43:49 (GMT)
committerThomas Haller <thaller@redhat.com>2014-08-27 11:22:22 (GMT)
commit592d665fbcdc46574ed1789b2a9073a5fcd5e4f3 (patch)
tree79db02be1393fdf61287f123821451ce6981625d /lib/route
parent06140c3ec9f0ab952fb42f112be7143d69688984 (diff)
downloadlibnl-592d665fbcdc46574ed1789b2a9073a5fcd5e4f3.zip
libnl-592d665fbcdc46574ed1789b2a9073a5fcd5e4f3.tar.gz
libnl-592d665fbcdc46574ed1789b2a9073a5fcd5e4f3.tar.bz2
cls: check data before memcpy() it
[thaller@redhat.com: I modified the condition "if (data && len)" in the original patch to just check "len > 0". Note that all call sites of meta_alloc() make sure to pass a valid data pointer with a non-zero length (anything else would be a bug). But indeed, calling memcpy with invalid src pointer is undefined behavior, even if len is zero.] Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route')
-rw-r--r--lib/route/cls/ematch/meta.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/route/cls/ematch/meta.c b/lib/route/cls/ematch/meta.c
index 6249bb1..e33c405 100644
--- a/lib/route/cls/ematch/meta.c
+++ b/lib/route/cls/ematch/meta.c
@@ -51,7 +51,8 @@ static struct rtnl_meta_value *meta_alloc(uint8_t type, uint16_t id,
value->mv_shift = shift;
value->mv_len = len;
- memcpy(value + 1, data, len);
+ if (len)
+ memcpy(value + 1, data, len);
return value;
}