You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working on addressing some of the issues found by coverity in papi (https://github.com/wcohen/papi/tree/coverity202307). In particular there were some possibly non-null terminated strings due to the string being larger than the buffer (wcohen@83ae483). When developing that particular fix I looked to see how other places in the papi had addressed that issue. Other places in were using snprintf and checking the value returned by the function. I noticed that some source code such as src/components/pcp/linux-pcp.c would flag errors when the return value was larger than the size passed in, but other such as src/components/sysdetect/nvidia_gpu.c and src/components/sysdetect/amd_gpu.c would flag an error if the size return was EQUAL to or larger than the size passed in. Both of the following links mention that the NULL at the end of the string is not counted in that total count returned by snprintf:
That would mean that a number of the tests checking the return value of snprintf are off by one. The tests should be flagging an error if snprintf returns a value equal to or greater than the buffer size rather than only greater than the buffer size.
The text was updated successfully, but these errors were encountered:
I was working on addressing some of the issues found by coverity in papi (https://github.com/wcohen/papi/tree/coverity202307). In particular there were some possibly non-null terminated strings due to the string being larger than the buffer (wcohen@83ae483). When developing that particular fix I looked to see how other places in the papi had addressed that issue. Other places in were using snprintf and checking the value returned by the function. I noticed that some source code such as src/components/pcp/linux-pcp.c would flag errors when the return value was larger than the size passed in, but other such as src/components/sysdetect/nvidia_gpu.c and src/components/sysdetect/amd_gpu.c would flag an error if the size return was EQUAL to or larger than the size passed in. Both of the following links mention that the NULL at the end of the string is not counted in that total count returned by snprintf:
https://www.geeksforgeeks.org/snprintf-c-library/
https://cplusplus.com/reference/cstdio/snprintf/
That would mean that a number of the tests checking the return value of snprintf are off by one. The tests should be flagging an error if snprintf returns a value equal to or greater than the buffer size rather than only greater than the buffer size.
The text was updated successfully, but these errors were encountered: