SWDEV-561611 - fix codeql errors by increasing printf buffer sizes (#1507)

* SWDEV-561611 - fix codeql errors by increasing printf buffer sizes

* Replace sprintf with snprintf to prevent potential buffer overflow

---------

Co-authored-by: cadolphe-amd <chris.adolphe@amd.com>
This commit is contained in:
Jimbo
2025-11-07 15:42:56 -05:00
committed by GitHub
parent de3b7322f2
commit 2006a411e5
3 changed files with 6 additions and 6 deletions
@@ -261,8 +261,8 @@ void OCLPerfMatrixTranspose::run(void) {
_perfInfo = (float)perf;
testDescString = "";
char str[64];
sprintf(str, "(%d,%d) matrix with (%2d,%2d) block size %fms (GB/s) ", width_, height_, blockSize_,
char str[90];
snprintf(str, sizeof(str), "(%d,%d) matrix with (%2d,%2d) block size %fms (GB/s) ", width_, height_, blockSize_,
blockSize_, (sec / (double)MAX_ITERATIONS) * 1000.);
testDescString += str;
}
@@ -777,8 +777,8 @@ void OCLPerfSHA256::run(void) {
}
testDescString += "with ";
char str[40];
sprintf(str, "%2d ip buff and %2d op buff ", num_input_buf_, num_output_buf_);
char str[45];
snprintf(str, sizeof(str), "%2d ip buff and %2d op buff ", num_input_buf_, num_output_buf_);
testDescString += str;
}
@@ -187,9 +187,9 @@ static void CL_CALLBACK notify_callback(const char* errinfo, const void* private
static void DumpTraceSI(unsigned int index, cl_ushort* tracePtr, size_t numOfBytes) {
FILE* outFile;
char file_name[16] = {0};
char file_name[31] = {0};
static unsigned int iii = 0;
sprintf(file_name, "TTrace%d%d.out", index, iii++);
snprintf(file_name, sizeof(file_name), "TTrace%d%d.out", index, iii++);
outFile = fopen(file_name, "w");