[vars.c:1664]: (error) Dangerous usage of 'varname' (strncpy doesn't always null-terminate it).
(void) strncpy(varname, name, 128); namelength = strlen(varname);
Maybe better code might be
strncpy(varname, name, 128); varname[127] = '\0'; namelength = strlen(varname);
Out of curiosity, what compiler do you use?
In 1.5 branch the strncpy() code isn't in the var.c file anymore. But I want to check if we have any other places in the code where the same compilation error can occur.
Thanks!
No reply from the user. Closing as "stale".
Got a reply from dcb via e-mail:
"Not a compiler, but a static analysis checker called cppcheck, available from sourceforge."
Reopening.
The output of the latest cppcheck on the latest Filebench code (1.5):
cvars/utils/mtwist/rdcctest.cc:210]: (error) Memory leak: params
[cvars/utils/mtwist/rdtest.c:242]: (error) Memory leak: params
[misc.c:128]: (error) Resource leak: cpuinfo
[parser_gram.y:1667]: (error) Resource leak: f
[parser_gram.y:3366]: (error) Memory leak: string
[parser_gram.y:3593]: (error) Memory leak: fspathlist
[parser_gram.y:3668]: (error) Memory leak: string
[stats.c:185]: (error) Resource leak: statfd
strncpy() problem is gone, but there are other issues.
Fixed with commit bb2d5d877676bf67870d6a1cbf56c0f921e3339a in Filebench-1.5 branch.
Two errors reported in cvars/utils/mtwist/rdcctest.cc and cvars/utils/mtwist/rdtest.c are not actual errors. Moreover, Filebench does not run that code.