All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Kevin Dawson <kevind@esi.com.au>
Cc: Roel Kluin <roel.kluin@gmail.com>,
	linux-hams@vger.kernel.org, netdev <netdev@vger.kernel.org>,
	Joerg Reuter <jreuter@yaina.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] ax25: unsigned cannot be less than 0 in ax25_ctl_ioctl()
Date: Tue, 13 Oct 2009 11:48:38 +0200	[thread overview]
Message-ID: <4AD44CF6.1070801@bfs.de> (raw)
In-Reply-To: <4AD3A67B.6070703@cerebellum.kd>



Kevin Dawson schrieb:
> Roel Kluin wrote:
> 
>>>  tmp_arg=ax25_ctl.arg * HZ;
>>>
>>>   if (arg == 0 || arg >  ULONG_MAX )
>>>         goto einval_put;
>>
>> I'm not sure, I think this would only work if we made `arg' an
>> unsigned long long.
> 
> That depends on the possible values of ax25_ctl.arg.
> 
>> +    if (ax25_ctl.arg * HZ > ULONG_MAX && ax25_ctl.cmd != AX25_KILL)
>> +        return -EINVAL;
> 
> Why the need to change arg before comparing it with a constant?  Let the
> compiler do the work:
> 
>     if (ax25_ctl.arg > ULONG_MAX / HZ && ...
> 
> Kevin
> 

i like this because it prevents a wrap around for stupid ax25_ctl.arg values but will not help when
ax25_ctl.arg * HZ is used later. NTL i think HZ does not need to be constant these days but i am not an
expert on that area.

  re,
   wh



  reply	other threads:[~2009-10-13  9:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-10 21:22 [PATCH] ax25: unsigned cannot be less than 0 in ax25_ctl_ioctl() Roel Kluin
2009-10-12 15:37 ` walter harms
2009-10-12 19:02   ` Roel Kluin
2009-10-12 21:58     ` Kevin Dawson
2009-10-13  9:48       ` walter harms [this message]
2009-10-13 21:50         ` Kevin Dawson
2009-10-14 15:26       ` Roel Kluin
2009-10-30  6:06         ` David Miller

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=4AD44CF6.1070801@bfs.de \
    --to=wharms@bfs.de \
    --cc=akpm@linux-foundation.org \
    --cc=jreuter@yaina.de \
    --cc=kevind@esi.com.au \
    --cc=linux-hams@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=roel.kluin@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.