PVS-StudioWarnings

PVS-Studio warning V557 for TPP

Nov 17th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. int main(int argc, char **argv) {
  2.   ...
  3.   char salt[3];
  4.   ...
  5.   salt[0] = (argc>2)?(argv[1][0]):rndChar[rand() % 64];
  6.   salt[1] = (argc>2)?(argv[1][1]):rndChar[rand() % 64];
  7.   salt[3] = 0;
  8.   ...
  9. }
  10.  
  11. This is what should have been written here: salt[2] = 0;
  12.  
  13. This suspicious code was found in TPP project by PVS-Studio static code analyzer.
  14. Warning message is:
  15. V557 Array overrun is possible. The '3' index is pointing beyond array bound. crypt crypt.cxx 567
  16.  
  17. 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