Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#312 closed defect (fixed)

dev_areca.cpp:146: sanity check after use - doesn't look right ?

Reported by: dcb314 Owned by: Christian Franke
Priority: major Milestone: Release 6.3
Component: all Version: 6.2
Keywords: Cc:

Description

I just ran the static analyser cppcheck over the source
code of version 6.2

It said many things, including

[dev_areca.cpp:146] -> [dev_areca.cpp:148]: (warning) Array 'cmds[5]' accessed at index 5, which is out of bounds. Otherwise condition 'arcmsr_cmd>=5' is redundant.

Source code is

sBuf.srbioctl.ControlCode = cmds[arcmsr_cmd];

if(arcmsr_cmd >= ARCMSR_CMD_TOTAL)
{

return -1;

}

Suggest move sanity check to before use.

Change History (4)

comment:1 by Christian Franke, 11 years ago

Milestone: Release 6.3
Owner: changed from somebody to Christian Franke
Status: newaccepted

comment:2 by Christian Franke, 11 years ago

Resolution: fixed
Status: acceptedclosed

comment:3 by Christian Franke, 11 years ago

Should be now fixed on trunc. More cppcheck related fixes will follow.

Interestingly I could not reproduce the (reasonable) warning message you mentioned. I used "cppcheck --enable=all --inconclusive --force dev_areca.cpp" with cppcheck 1.54 and 1.63 on dev_areca.cpp from 6.2.

in reply to:  3 comment:4 by dcb314, 11 years ago

Replying to chrfranke:

Interestingly I could not reproduce the (reasonable) warning message you mentioned.

I use cppcheck trunk development code, via svn.

Note: See TracTickets for help on using tickets.