public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Olivier Galibert <galibert@pobox.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] dvb: copy_from_user checks
Date: Fri, 19 Feb 2010 14:59:16 +0100	[thread overview]
Message-ID: <20100219135915.GA57188@dspnet.fr.eu.org> (raw)
In-Reply-To: <20100218183753.8212.3164.stgit@localhost.localdomain>

On Thu, Feb 18, 2010 at 06:39:16PM +0000, Alan Cox wrote:
> I don't believe the frag count can ever get loaded with a negative value
> even with the -2 but neither the compiler (nor I ;)) can prove it so keep
> us both happy.
> 
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> ---
> 
>  drivers/media/dvb/dvb-core/dvb_ca_en50221.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
> index cb22da5..2cf03e9 100644
> --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
> +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
> @@ -1280,7 +1280,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
>  	u8 slot, connection_id;
>  	int status;
>  	u8 fragbuf[HOST_LINK_BUF_SIZE];
> -	int fragpos = 0;
> +	unsigned int fragpos = 0;
>  	int fraglen;
>  	unsigned long timeout;
>  	int written;
> @@ -1308,6 +1308,8 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
>  		fraglen = ca->slot_info[slot].link_buf_size - 2;
>  		if ((count - fragpos) < fraglen)
>  			fraglen = count - fragpos;
> +		if (fraglen < 0)
> +		        fraglen = 0;

If fragpos is unsigned int, then the < fraglen comparison is going to
be unsigned, which is probably not what you want either, is it?

  OG.


      reply	other threads:[~2010-02-19 13:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 18:39 [RESEND PATCH] dvb: copy_from_user checks Alan Cox
2010-02-19 13:59 ` Olivier Galibert [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=20100219135915.GA57188@dspnet.fr.eu.org \
    --to=galibert@pobox.com \
    --cc=linux-kernel@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