iio: Reject trailing garbage when parsing fixed point numbers
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 22 Oct 2012 11:15:00 +0000 (12:15 +0100)
committerJonathan Cameron <jic23@kernel.org>
Fri, 2 Nov 2012 09:43:48 +0000 (09:43 +0000)
When parsing a fixed point number IIO stops parsing the string once it has
reached the last requested decimal place. This means that the remainder of the
string is silently accepted regardless, of whether it is part of a valid number
or not. This patch modifies the code to scan the whole string and only accept
valid numbers. Since fract_mult is 0 after the last decimal place any digit that
may follows won't affect the result.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/industrialio-core.c

index 0994239361bab6854d4462b9f200f50cc73d3a70..7bb570b7a4af64f0bad899a23a2dcee3ba68cf85 100644 (file)
@@ -445,8 +445,6 @@ static ssize_t iio_write_channel_info(struct device *dev,
                                integer = integer*10 + *buf - '0';
                        else {
                                fract += fract_mult*(*buf - '0');
-                               if (fract_mult == 1)
-                                       break;
                                fract_mult /= 10;
                        }
                } else if (*buf == '\n') {