From dc8b5d6e633f8e54f70594d0be87aaf401ea0559 Mon Sep 17 00:00:00 2001 From: Hartmut Knaack Date: Sun, 31 May 2015 14:39:59 +0200 Subject: tools:iio:iio_utils: check amount of matches fscanf() usually returns the number of input items successfully matched and assigned, which can be fewer than provided (or even zero). Add a check in iioutils_get_type() to make sure all items are matched. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/iio') diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index f12bc2e81c80..c5b4136e648a 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -144,6 +144,10 @@ int iioutils_get_type(unsigned *is_signed, ret = -errno; printf("failed to pass scan type description\n"); goto error_close_sysfsfp; + } else if (ret != 5) { + ret = -EIO; + printf("scan type description didn't match\n"); + goto error_close_sysfsfp; } *be = (endianchar == 'b'); *bytes = padint / 8; -- cgit