Skip to content
Snippets Groups Projects
user avatar
Philippe Canal authored
The original warning is inaccurate as by construction lentit+ktitle is less than the size of the buffer (1024)
because of the line:

      if (lentit > 250-ktitle) lentit = 250-ktitle;

However, the warning detections implementation (as of gcc 8.2) can not detect this (even if the actual length
is use in any away, for example:

      strncpy(&line[ktitle],memberTitle,std::min(sizeof line - ktitle, lentit));

still produce the warning.

So we switch from strncpy to strlcpy for which gcc 8.2 does not (yet?) warn.

/local2/pcanal/cint_working/rootcling/root/core/meta/src/TClass.cxx: In member function ‘virtual void TDumpMembers::Inspect(TClass*, const char*, const char*, const void*, Bool_t)’:
/local2/pcanal/cint_working/rootcling/root/core/meta/src/TClass.cxx:686:14: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
       strncpy(&line[ktitle],memberTitle,lentit);
       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/local2/pcanal/cint_working/rootcling/root/core/meta/src/TClass.cxx:684:28: note: length computed here
       Int_t lentit = strlen(memberTitle);
                      ~~~~~~^~~~~~~~~~~~~
358db2a5
History
Name Last commit Last update