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>
This commit is contained in:
parent
06140c3ec9
commit
592d665fbc
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue