]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iio: Do not accept multiple '.' in 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:47 +0000 (09:43 +0000)
Currently when parsing a fix-point number we silently skip any additional '.'
found in the string.  E.g. '1.2.3.4' gets parsed as '1.234'. This patch
disallows this and returns an error if more than one '.' is encountered.

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

index 37650a72b31f11fc75d0afb6123233c724ce8270..0994239361bab6854d4462b9f200f50cc73d3a70 100644 (file)
@@ -454,7 +454,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
                                break;
                        else
                                return -EINVAL;
-               } else if (*buf == '.') {
+               } else if (*buf == '.' && integer_part) {
                        integer_part = false;
                } else {
                        return -EINVAL;