PVS-StudioWarnings

PVS-Studio warning V511 for samba

Nov 20th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #define FSTRING_LEN 256
  2. typedef char fstring[FSTRING_LEN];
  3.  
  4. char *safe_strcpy(char *dest,const char *src, size_t maxlength)
  5. #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
  6.  
  7. static bool parse_wbinfo_domain_user(
  8.   const char *domuser, fstring domain, fstring user)
  9. {
  10.   ....
  11.     /* Maybe it was a UPN? */
  12.     if ((p = strchr(domuser, '@')) != NULL) {
  13.       fstrcpy(domain, "");
  14.       fstrcpy(user, domuser);
  15.       return true;
  16.     }
  17.   ....
  18. }
  19.  
  20. This suspicious code was found in samba project by PVS-Studio static code analyzer.
  21. Warning message is:
  22. V511 The sizeof() operator returns size of the pointer, and not of the array, in 'sizeof ((domain))' expression. wbinfo.c 124
  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