pci-assign: Fix potential read beyond buffer on -EBUSY

readlink() doesn't write a terminating null byte.
assign_failed_examine() passes the unterminated string to strrchr().
Oops.  Terminate it.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
Markus Armbruster 2014-02-26 10:30:03 -07:00 committed by Alex Williamson
parent 13665a2d2f
commit 82d0794565

View File

@ -743,6 +743,7 @@ static void assign_failed_examine(AssignedDevice *dev)
goto fail; goto fail;
} }
driver[r] = 0;
ns = strrchr(driver, '/'); ns = strrchr(driver, '/');
if (!ns) { if (!ns) {
goto fail; goto fail;