Page MenuHome

Force null termination on the elbeem error strings
Needs ReviewPublic

Authored by Martin Preisler (mpreisler) on Jul 4 2018, 11:02 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

gcc8 rightly complains about this:

../intern/elbeem/intern/utilities.cpp: In function ‘void setElbeemErrorString(const char*)’:
../intern/elbeem/intern/utilities.cpp:62:9: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 256 equals destination size [-Wstringop-truncation]
  strncpy(gElbeemErrorString, set, 256);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../intern/elbeem/intern/utilities.cpp: In function ‘void messageOutputFunc(std::__cxx11::string, int, std::__cxx11::string, myTime_t)’:
../intern/elbeem/intern/utilities.cpp:369:10: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound 256 equals destination size [-Wstringop-truncation]
   strncpy(gElbeemErrorString,sout.str().c_str(), 256);

If the source string is more than 256 characters long strncpy will copy the first 256 characters and then it will stop, without null terminating the destination buffer.

Not sure if this is a real risk but better be careful :-)

Diff Detail

Repository
rB Blender

Event Timeline