diff options
author | Hartmut Knaack <knaack.h@gmx.de> | 2015-05-31 08:39:59 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-05-31 12:42:34 -0400 |
commit | dc8b5d6e633f8e54f70594d0be87aaf401ea0559 (patch) | |
tree | f5e63a71ac3522b744c32ae292fe7bbb5563e240 /tools/iio | |
parent | 8e926134ef15267f65ddfc7389c8078234610295 (diff) |
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 <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools/iio')
-rw-r--r-- | tools/iio/iio_utils.c | 4 |
1 files changed, 4 insertions, 0 deletions
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, | |||
144 | ret = -errno; | 144 | ret = -errno; |
145 | printf("failed to pass scan type description\n"); | 145 | printf("failed to pass scan type description\n"); |
146 | goto error_close_sysfsfp; | 146 | goto error_close_sysfsfp; |
147 | } else if (ret != 5) { | ||
148 | ret = -EIO; | ||
149 | printf("scan type description didn't match\n"); | ||
150 | goto error_close_sysfsfp; | ||
147 | } | 151 | } |
148 | *be = (endianchar == 'b'); | 152 | *be = (endianchar == 'b'); |
149 | *bytes = padint / 8; | 153 | *bytes = padint / 8; |