PVS-StudioWarnings

PVS-Studio warning V645 for ReactOS

Nov 20th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. void shell(int argc, const char *argv[])
  2. {
  3.   char CmdLine[MAX_PATH];
  4.   ....
  5.   strcpy( CmdLine, ShellCmd );
  6.  
  7.   if (argc > 1)
  8.   {
  9.     strncat(CmdLine, " /C", MAX_PATH);
  10.   }
  11.  
  12.   for (i=1; i<argc; i++)
  13.   {
  14.     strncat(CmdLine, " ", MAX_PATH);
  15.     strncat(CmdLine, argv[i], MAX_PATH);
  16.   }
  17.   ....
  18. }
  19.  
  20. This suspicious code was found in ReactOS project by PVS-Studio static code analyzer.
  21. Warning message is:
  22. V645 The 'strncat' function call could lead to the 'CmdLine' buffer overflow. The bounds should not contain the size of the buffer, but a number of characters it can hold. cmds.c 1314
  23.  
  24. 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