From: Joshua Clayton Date: Wed, 18 Nov 2015 22:30:41 +0000 (-0800) Subject: spi: spidev_test: check error X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a20874f78be633b9e3a505d5f191735188b110a5;p=linux-beck.git spi: spidev_test: check error Check the result of sscanf to verify a result was found. report and error and abort if pattern was not found. Signed-off-by: Joshua Clayton Signed-off-by: Mark Brown --- diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c index 02fc3a44901b..322370dbc770 100644 --- a/tools/spi/spidev_test.c +++ b/tools/spi/spidev_test.c @@ -86,13 +86,17 @@ static void hex_dump(const void *src, size_t length, size_t line_size, char *pre static int unescape(char *_dst, char *_src, size_t len) { int ret = 0; + int match; char *src = _src; char *dst = _dst; unsigned int ch; while (*src) { if (*src == '\\' && *(src+1) == 'x') { - sscanf(src + 2, "%2x", &ch); + match = sscanf(src + 2, "%2x", &ch); + if (!match) + pabort("malformed input string"); + src += 4; *dst++ = (unsigned char)ch; } else {