]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: don't overwrite stack when getting ethtool gfeatures
authorLaine Stump <laine@laine.org>
Tue, 11 Aug 2015 17:45:46 +0000 (13:45 -0400)
committerLaine Stump <laine@laine.org>
Tue, 11 Aug 2015 19:29:14 +0000 (15:29 -0400)
commitbfaaa2b681018f3705bae17c001700a03f67d7c4
treecc401f825235d5aea07c8ca2337a0efda1d866fa
parent133c25c81c9ef79053d8d67a1e897846f9d7adb5
util: don't overwrite stack when getting ethtool gfeatures

This fixes the crash described here:

 https://www.redhat.com/archives/libvir-list/2015-August/msg00162.html

In short, we were calling ioctl(SIOCETHTOOL) pointing to a too-short
object that was a local on the stack, resulting in the memory past the
end of the object being overwritten. This was because the struct used
by the ETHTOOL_GFEATURES command of SIOCETHTOOL ends with a 0-length
array, but we were telling ethtool that it could use 2 elements on the
array.

The fix is to allocate the necessary memory with VIR_ALLOC_VAR(),
including the extra length needed for a 2 element array at the end.
src/util/virnetdev.c