PVS-StudioWarnings

PVS-Studio warning V557 for iecsdk

Nov 20th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #define PL_MAX_PATH 255
  2. #define PL2GANFLIA_COUNTER_MAX_LENGTH PL_MAX_PATH
  3.  
  4. char name[PL_MAX_PATH];
  5.  
  6. int main(int argc, char *argv[]) {
  7.   ...
  8.   p->pl_counters_data[i].name[
  9.     PL2GANFLIA_COUNTER_MAX_LENGTH
  10.   ] = '\0';
  11.   ...
  12. }
  13.  
  14. This is what should have been written here: PL2GANFLIA_COUNTER_MAX_LENGTH - 1
  15.  
  16.  
  17. This suspicious code was found in iecsdk project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V557 Array overrun is possible. The '255' index is pointing beyond array bound. pl2ganglia pl2ganglia.c 1114
  20.  
  21. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment