From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 2/3] iio: Reject trailing garbage when parsing fixed point numbers
Date: Mon, 22 Oct 2012 13:15:14 +0200 [thread overview]
Message-ID: <1350904515-696-2-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1350904515-696-1-git-send-email-lars@metafoo.de>
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>
---
drivers/iio/industrialio-core.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a2e9953..fe593bf 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -440,8 +440,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') {
--
1.7.10.4
next prev parent reply other threads:[~2012-10-22 11:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 11:15 [PATCH 1/3] iio: Do not accept multiple '.' in fixed point numbers Lars-Peter Clausen
2012-10-22 11:15 ` Lars-Peter Clausen [this message]
2012-11-02 9:45 ` [PATCH 2/3] iio: Reject trailing garbage when parsing " Jonathan Cameron
2012-10-22 11:15 ` [PATCH 3/3] iio: Accept a leading '+' sign " Lars-Peter Clausen
2012-11-02 9:46 ` Jonathan Cameron
2012-11-02 9:44 ` [PATCH 1/3] iio: Do not accept multiple '.' in " Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350904515-696-2-git-send-email-lars@metafoo.de \
--to=lars@metafoo.de \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).