qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 6/7] lan9118: fix a buffer overflow
Date: Mon, 10 Jan 2011 21:50:16 +0000	[thread overview]
Message-ID: <AANLkTikN2vZ0SXeb7H7J144aGEzoSmO8GejiM+0yRPAt@mail.gmail.com> (raw)
In-Reply-To: <m362txexln.fsf@blackfin.pond.sub.org>

On Mon, Jan 10, 2011 at 12:45 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Blue Swirl <blauwirbel@gmail.com> writes:
>
>> Fix a buffer overflow, reported by cppcheck:
>> [/src/qemu/hw/lan9118.c:849]: (error) Buffer access out-of-bounds: s.eeprom
>>
>> All eeprom handling code assumes that the size of eeprom is 128.
>>
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>> ---
>>  hw/lan9118.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/lan9118.c b/hw/lan9118.c
>> index a988664..1bb829e 100644
>> --- a/hw/lan9118.c
>> +++ b/hw/lan9118.c
>> @@ -187,7 +187,7 @@ typedef struct {
>>      uint32_t phy_int_mask;
>>
>>      int eeprom_writable;
>> -    uint8_t eeprom[8];
>> +    uint8_t eeprom[128];
>>
>>      int tx_fifo_size;
>>      LAN9118Packet *txp;
>
> Covers all the obvious accesses except for a couple of s->eeprom[addr]
> in lan9118_eeprom_cmd().  addr is a parameter there, and the actual
> argument is val & 0xff, in lan9118_writel().  What if val & 0xff >= 128?

Should the size be 256 and cases with 128 changed accordingly? Or mask
changed to 0x7f?

  reply	other threads:[~2011-01-10 21:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-08 18:25 [Qemu-devel] [PATCH 6/7] lan9118: fix a buffer overflow Blue Swirl
2011-01-10 12:45 ` Markus Armbruster
2011-01-10 21:50   ` Blue Swirl [this message]
2011-01-10 22:14     ` Peter Maydell
2011-01-11  9:10       ` Markus Armbruster

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=AANLkTikN2vZ0SXeb7H7J144aGEzoSmO8GejiM+0yRPAt@mail.gmail.com \
    --to=blauwirbel@gmail.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).