lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 11 Nov 2009 13:09:57 -0200
From:	Thiago Farina <tfransosi@...il.com>
To:	André Goddard Rosa <andre.goddard@...il.com>
Cc:	tabbott@...lice.com, alan-jenkins@...fmail.co.uk,
	rusty@...tcorp.com.au, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] bsearch: prevent overflow when computing middle 
	comparison element

On Tue, Nov 10, 2009 at 1:00 PM, André Goddard Rosa
<andre.goddard@...il.com> wrote:
>  void *bsearch(const void *key, const void *base, size_t num, size_t size,
>              int (*cmp)(const void *key, const void *elt))
>  {
> -       int start = 0, end = num, mid, result;
> +       size_t start = 0, end = num;
> +       int result;
>
>        while (start < end) {
> -               mid = (start + end) / 2;
> +               size_t mid = start + (end - start) / 2;
I think it is more readable if you could keep the mid variable outside
of the while loop.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists