PVS-StudioWarnings

PVS-Studio warning V541 for CPU Identifying Tool

Nov 19th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. char * OSDetection ()
  2. {
  3.   ...
  4.   sprintf (szOperatingSystem, "%sversion %d.%d %s (Build %d)",
  5.            szOperatingSystem,
  6.            osvi.dwMajorVersion,
  7.            osvi.dwMinorVersion,
  8.            osvi.szCSDVersion,
  9.            osvi.dwBuildNumber & 0xFFFF);
  10.   ...
  11.   sprintf (szOperatingSystem, "%s%s(Build %d)",
  12.            szOperatingSystem, osvi.szCSDVersion,
  13.            osvi.dwBuildNumber & 0xFFFF);
  14.   ...
  15. }
  16.  
  17. The code might work, but this is a dangerous game.
  18.  
  19. This suspicious code was found in CPU Identifying Tool project by PVS-Studio static code analyzer.
  20. Warning message is:
  21. V541 It is dangerous to print the string 'szOperatingSystem' into itself. stickies camel.cpp 572
  22.  
  23. 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