Commit 02330acd authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

iio: Reject trailing garbage when parsing fixed point numbers

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 8f1b7eb1
...@@ -445,8 +445,6 @@ static ssize_t iio_write_channel_info(struct device *dev, ...@@ -445,8 +445,6 @@ static ssize_t iio_write_channel_info(struct device *dev,
integer = integer*10 + *buf - '0'; integer = integer*10 + *buf - '0';
else { else {
fract += fract_mult*(*buf - '0'); fract += fract_mult*(*buf - '0');
if (fract_mult == 1)
break;
fract_mult /= 10; fract_mult /= 10;
} }
} else if (*buf == '\n') { } else if (*buf == '\n') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment