ScanLinuxKernel/20120218-arrayindex
From cppcheck
Scan report
Project: Linux Kernel 3.0.1
Date: 2012-02-18
Cppcheck: latest git head
Commands used:
cppcheck -j2 --xml-version=2 drivers 2> cppcheck-results-120218.xml xsltproc arrayindex.xsl cppcheck-results-120218.xml
arrayindex.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="results/errors/error[@id='arrayIndexOutOfBounds']">[<xsl:value-of select="location/@file"/>:<xsl:value-of select="location/@line"/>] <xsl:value-of select="@msg"/><xsl:text> </xsl:text></xsl:for-each> </xsl:template> </xsl:stylesheet>
Results with comments
[drivers/cdrom/cdrom.c:491] Array 'buffer[8]' index 100 out of bounds
=> false positive ('100' is the default struct size)
[drivers/media/dvb/pluto2/pluto2.c:484] Array 'buf[4]' index 4 out of bounds [drivers/media/dvb/pluto2/pluto2.c:485] Array 'buf[4]' index 4 out of bounds [drivers/media/dvb/pluto2/pluto2.c:486] Array 'buf[4]' index 4 out of bounds [drivers/media/dvb/pluto2/pluto2.c:488] Array 'buf[4]' index 5 out of bounds => false positive since the code is unreachable (never true: sizeof(buf) == 6)
[drivers/mtd/nand/bcm_umi_bch.c:165] Array 'eccCalc[3]' index 3 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:165] Array 'eccCalc[3]' index 4 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:165] Array 'eccCalc[3]' index 5 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:165] Array 'eccCalc[3]' index 6 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:166] Array 'eccCalc[3]' index 7 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:166] Array 'eccCalc[3]' index 8 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:166] Array 'eccCalc[3]' index 9 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:166] Array 'eccCalc[3]' index 10 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:167] Array 'eccCalc[3]' index 11 out of bounds
[drivers/mtd/nand/bcm_umi_bch.c:167] Array 'eccCalc[3]' index 12 out of bounds
=> These are true positives. these errors happen if :
NAND_ECC_BCH is not defined (#define NAND_ECC_NUM_BYTES 3)
NAND_BCM_UMI_DEBUG is defined
[drivers/staging/comedi/drivers/pcmmio.c:561] Array 'irq[1]' index 1 out of bounds => true positive
[drivers/staging/comedi/drivers/pcmmio.c:562] Array 'irq[1]' index 1 out of bounds => true positive
[drivers/staging/cxt1e1/comet.c:415] Array 'table[24][5]' index table[24][0] out of bounds => true positive
