public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "André Goddard Rosa" <andre.goddard@gmail.com>
To: tabbott@ksplice.com, alan-jenkins@tuffmail.co.uk,
	rusty@rustcorp.com.au, linux-kernel@vger.kernel.org
Cc: "André Goddard Rosa" <andre.goddard@gmail.com>
Subject: [PATCH v4 0/2] bsearch: fix overflow and avoid unnecessary calculation
Date: Tue, 10 Nov 2009 13:00:23 -0200	[thread overview]
Message-ID: <cover.1257864001.git.andre.goddard@gmail.com> (raw)

Fix a rare overflow situation which can occur when working with large arrays.
Also, remove an unneeded calculation.

changelog:
    v4: fix the overflow which could still happen when the number of array
        elements to search approached the maximum value of size_t and to
        find the key element we would need to traverse the whole binary tree
        (making 'start' idx tend towards 'end' idx), as pointed by review
        feedback from Rusty Russell (thanks!)
    v3: fix the comment/example of patch 02/02 at v2 patch series
    v2: fix a bug introduced into 01/02 of the v1 patch series
    v1: initial submission

André Goddard Rosa (2):
  bsearch: avoid unneeded decrement arithmetic
  bsearch: prevent overflow when computing middle comparison element

 lib/bsearch.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)


                 reply	other threads:[~2009-11-11 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=cover.1257864001.git.andre.goddard@gmail.com \
    --to=andre.goddard@gmail.com \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tabbott@ksplice.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox