memif: fix vector overflow when copying strings 82/20582/2
authorBenoît Ganne <bganne@cisco.com>
Wed, 10 Jul 2019 12:56:26 +0000 (14:56 +0200)
committerDamjan Marion <dmarion@me.com>
Wed, 24 Jul 2019 12:07:01 +0000 (12:07 +0000)
commit5a61f64f6e7c812f9bfb5d4219e1a22798368582
treeb34e2a651090821ed35c52e1cada5bab7a569d00
parent8c1280fd9ade67ecfca35c545fbdcb49d5d4325e
memif: fix vector overflow when copying strings

When memif sends back socket messages containing strings, we copy
vectors into C-string. Unfortunately, most vectors are not
null-terminated, causing strncpy() read overflow. Moreover, strncpy()
does not null-terminate string in case of max length reached.
This patch introduces helpers to safely copy strings from vectors.

Type: fix
Fixes: d6042d4f1ea0baf02bc87c72960a331a9e08dfab

Change-Id: I38489ec8d2a5d4a42b9abde1aa3dfdbd06ebe024
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/memif/socket.c