Advertisement
PVS-StudioWarnings

PVS-Studio warning V547 for ReactOS

Nov 24th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. BOOL PrepareService(LPCTSTR ServiceName)
  2. {
  3.   DWORD LeftOfBuffer = sizeof(ServiceKeyBuffer) /
  4.                        sizeof(ServiceKeyBuffer[0]);
  5.   ....
  6.   LeftOfBuffer -= _tcslen(SERVICE_KEY);
  7.   ....
  8.   LeftOfBuffer -= _tcslen(ServiceName);
  9.   ....
  10.   LeftOfBuffer -= _tcslen(PARAMETERS_KEY);
  11.   ....
  12.   if (LeftOfBuffer < 0)
  13.   {
  14.     DPRINT1("Buffer overflow for service name: '%s'\n",
  15.             ServiceName);
  16.     return FALSE;
  17.   }
  18.   ....
  19. }
  20.  
  21. There are a lot of such fragments in ReactOS, but I cannot say for sure how critical they are.
  22.  
  23. This suspicious code was found in ReactOS project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V547 Expression 'LeftOfBuffer < 0' is always false. Unsigned type value is never < 0. svchost svchost.c 56
  26.  
  27. 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
Advertisement