[cppcheck] buffer access out of bounds

Bug #695507 reported by orbitcowboy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zsnes (Debian)
Fix Released
Unknown
zsnes (Ubuntu)
Incomplete
Undecided
Unassigned

Bug Description

Binary package hint: zsnes

during a check with the static code analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) the tool discovered a severe error in the sources of zsnes_1.510.tar.gz. Here is the report of cppcheck:

./src/initc.c:2764 [error] - Array 'SPCRAM[65472]' index 65535 out of bounds

Take a look at the source (here is reduced sample to show what is going on):

#include <iostream>

int main()
{
    int i;
    int SPCRAM[65472];
// std::cout << 0x40 << std::endl;
// std::cout << 0xFFC0 << std::endl;
    for(i = 0;i<0x40;i++)
    {
      SPCRAM[0xFFC0+i] = 0;
    }
}

The buffer SPCRAM is accessed out bounds.

Best regards from the cppheck-team.

Revision history for this message
Etienne Millon (etienne-millon) wrote :

Hello,

The cppcheck run on Debian signaled several other warnings : http://qa.debian.org/daca/cppcheck/sid/zsnes_1.510-2.2.html

Changed in zsnes (Debian):
status: Unknown → New
Revision history for this message
shankao (shankao) wrote :

I just had a look to zsnes sources and seem to have changed since your bug report.
Is this problem still happening?

Changed in zsnes (Ubuntu):
status: New → Incomplete
Revision history for this message
Etienne Millon (etienne-millon) wrote : Re: [Bug 695507] Re: [cppcheck] buffer access out of bounds

Hello,

I think that this is still applicable to the latest version:

https://qa.debian.org/daca/cppcheck/sid/zsnes_1.510+bz2-1.html

Best,

Revision history for this message
shankao (shankao) wrote :

Agree.

This one is pretty obvious:
./src/initc.c:2764 [error] - Array 'SPCRAM[65472]' index 65535 out of bounds

Problem is that zsnes upstream seems to have died long ago, so this leaves code maintenance to debian/ubuntu... maybe you can branch the code into launchpad and submit some fixes?

Changed in zsnes (Debian):
status: New → Fix Released
Revision history for this message
Stéphane (stephane-treboux) wrote :

This issue should become irrelevant because the package zsnes was recently removed from the repositories with 23.10 (mantic).

The package zsnes was maintained by Debian and the maintainer decided to remove it because the development of ZSNES has ceased in 2007.

The issue is discussed in two Debian bug reports:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1039564
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1039568

For your convenience I attached a copy of the last Ubuntu package for zsnes which I downloaded from https://packages.ubuntu.com/lunar/zsnes; the link will die soon when lunar goes out of support.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.