usbip: Fix potential format overflow in userspace tools
authorJonathan Dieter <jdieter@lesbg.com>
Mon, 27 Feb 2017 08:31:03 +0000 (10:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2017 04:16:56 +0000 (13:16 +0900)
commite5dfa3f902b9a642ae8c6997d57d7c41e384a90b
tree7ffbc5d1292e713efc36c224e19099dc343214fb
parent2c93e790e8253552227bf9b46a8d49dca3f71b06
usbip: Fix potential format overflow in userspace tools

The usbip userspace tools call sprintf()/snprintf() and don't check for
the return value which can lead the paths to overflow, truncating the
final file in the path.

More urgently, GCC 7 now warns that these aren't checked with
-Wformat-overflow, and with -Werror enabled in configure.ac, that makes
these tools unbuildable.

This patch fixes these problems by replacing sprintf() with snprintf() in
one place and adding checks for the return value of snprintf().

Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/usb/usbip/libsrc/usbip_common.c
tools/usb/usbip/libsrc/usbip_host_common.c