libmultipath: fix length issues in get_vpd_sgio
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 9 Oct 2018 23:03:04 +0000 (18:03 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 10 Oct 2018 06:09:31 +0000 (08:09 +0200)
commit0f5e45b02508ca7ac93b63e07491edaf2e60cbc7
treef8cbc48f007fc6ceab58a57fad033fcfc3630f39
parent8f9ac30dcb144d4ce79f88e8a01fba0968da3a07
libmultipath: fix length issues in get_vpd_sgio

When get_vpd_sgio() finds out that the vpd info needed to be truncated
to fit in the buffer, it doesn't trucate the size as well,  which allows
it to overwrite the buffer. Also, in once len is set to -ENODATA,
get_vpd_sgio() should exit, instead of using the negative len in
memcpy(). Found by coverity.

Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/discovery.c