From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Cameron <jic23@cam.ac.uk>,
devel@driverdev.osuosl.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH] iio: iio_enum_available_read: Prevent possible buffer overflow
Date: Wed, 06 Jun 2012 09:34:27 +0100 [thread overview]
Message-ID: <4FCF1613.2000002@kernel.org> (raw)
In-Reply-To: <1338913452-26786-1-git-send-email-lars@metafoo.de>
On 6/5/2012 5:24 PM, Lars-Peter Clausen wrote:
> Use scnprint instead of snprintf, because snprintf returns the number of bytes
> that would have been written to the buffer if there was enough space, and as a
> result writing to buf[len-1] might cause a access beyond the buffers limits.
>
> Reported-by: Dan Carpenter<dan.carpenter@oracle.com>
> Signed-off-by: Lars-Peter Clausen<lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
> drivers/iio/industrialio-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 56a3c0b..cf9ecd0 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -300,7 +300,7 @@ ssize_t iio_enum_available_read(struct iio_dev *indio_dev,
> return 0;
>
> for (i = 0; i< e->num_items; ++i)
> - len += snprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
> + len += scnprintf(buf + len, PAGE_SIZE - len, "%s ", e->items[i]);
>
> /* replace last space with a newline */
> buf[len - 1] = '\n';
prev parent reply other threads:[~2012-06-06 8:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 16:24 [PATCH] iio: iio_enum_available_read: Prevent possible buffer overflow Lars-Peter Clausen
2012-06-06 8:34 ` Jonathan Cameron [this message]
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=4FCF1613.2000002@kernel.org \
--to=jic23@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@cam.ac.uk \
--cc=lars@metafoo.de \
--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).