mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lasse Collin <lasse.collin@tukaani.org>
To: Andreas Schwab <schwab@linux-m68k.org>, Jesper Juhl <jj@chaosbits.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Possible array overrun in lzma_reset()
Date: Mon, 24 Jan 2011 15:19:07 +0200	[thread overview]
Message-ID: <201101241519.07547.lasse.collin@tukaani.org> (raw)
In-Reply-To: <m2bp38r33j.fsf@igel.home>

On 2011-01-23 Andreas Schwab wrote:
> Jesper Juhl <jj@chaosbits.net> writes:
>
> > 787           probs = s->lzma.is_match[0];
> > At conditional (1): "i < 14134UL" taking true path
> > At conditional (2): "i < 14134UL" taking true path
> > At conditional (3): "i < 14134UL" taking true path
> > 788           for (i = 0; i < PROBS_TOTAL; ++i)
> > Event overrun-local: Overrunning static array of size 32 bytes at byte position 28266 by indexing pointer "probs" with index variable "i".
> > Event overrun-local: Note: These bugs are often difficult to see at first glance. Coverity recommends a close inspection of the events leading to this overrun.
> > 789                   probs[i] = RC_BIT_MODEL_TOTAL / 2;
> > ...
> >
> > I looked into the report and found that 's->lzma.is_match' is
> >       uint16_t is_match[STATES][POS_STATES_MAX]
> > where 'STATES' is '#define STATES 12' and 'POS_STATES_MAX' is '#define POS_STATES_MAX (1 << 4)'.
> >
> > So I think the checker has a point.
>
> The loop treats the part of the structure from is_match to the end as
> a single array of PROBS_TOTAL uint16_t (which it is, in effect).

Correct. The comment in the code tries to say it too:

    * All probabilities are initialized to the same value. This hack
    * makes the code smaller by avoiding a separate loop for each
    * probability array.

So there is no bug.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

      reply	other threads:[~2011-01-24 13:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22 20:41 Jesper Juhl
2011-01-22 22:22 ` Andreas Schwab
2011-01-24 13:19   ` Lasse Collin [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=201101241519.07547.lasse.collin@tukaani.org \
    --to=lasse.collin@tukaani.org \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@linux-m68k.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

all inboxes | Powered by JetHome®