Skip to content

Commit 4a9ef8a

Browse files
juanrod2sys_zuul
authored andcommitted
Klocwork Fixes
Change-Id: Id16b0aedbce2dc70bdf3d8b2cde5d50fb7245cbc
1 parent ae61f22 commit 4a9ef8a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

IGC/OCLFE/igd_fcl_mcl/source/clang_tb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ namespace FCL
132132
}
133133

134134
// Just return the string
135-
strncpy((char*)pValue, envVal, size);
135+
strncpy_s((char*)pValue, size, envVal, size);
136136

137137
return true;
138138
}

IGC/common/igc_regkeys.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
#include "common/LLVMWarningsPop.hpp"
3333
#include "common/SysUtils.hpp"
3434
#include "3d/common/iStdLib/File.h"
35+
#include "secure_mem.h"
36+
#include "secure_string.h"
3537

3638
#include <string>
3739
#include <cassert>
@@ -76,7 +78,7 @@ static bool ReadIGCEnv(
7678
}
7779

7880
// Just return the string
79-
strncpy( (char*)pValue, envVal, size );
81+
strncpy_s( (char*)pValue, size, envVal, size );
8082

8183
return true;
8284
}
@@ -232,7 +234,7 @@ static void ParseCStringVector(std::vector<char *> &OutputVector,
232234

233235
// Everything from 0 to Pos is the next word to copy.
234236
char *NewStr = (char*)malloc(Pos + 1);
235-
memcpy(NewStr, WorkStr.data(), Pos);
237+
memcpy_s(NewStr, Pos + 1, WorkStr.data(), Pos);
236238
NewStr[Pos] = 0;
237239
OutputVector.push_back(NewStr);
238240

@@ -295,7 +297,7 @@ static void setRegkeyFromOption(
295297
if(!vstring.empty())
296298
{
297299
char* s = (char*)pRegkeyVar;
298-
strcpy(s, vstring.c_str());
300+
strcpy_s(s, vstring.size(), vstring.c_str());
299301
isKeySet = true;
300302
}
301303
}
@@ -352,7 +354,7 @@ static void declareIGCKey(std::string& line, const char* dataType, const char* r
352354
setRegkeyFromOption(line, dataType, regkeyName, &value, isSet);
353355
if (isSet)
354356
{
355-
memcpy(regKey->m_string, value, sizeof(value));
357+
memcpy_s(regKey->m_string, sizeof(value), value, sizeof(value));
356358
regKey->hashes = hashes;
357359
}
358360
}
@@ -408,7 +410,7 @@ static void LoadFromRegKeyOrEnvVar()
408410

409411
if (isSet)
410412
{
411-
memcpy(pRegKeyVariable[i].m_string, value, sizeof(value));
413+
memcpy_s(pRegKeyVariable[i].m_string, sizeof(value), value, sizeof(value));
412414
}
413415
}
414416
}

visa/CISA.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ DoubleFloat : DOUBLEFLOAT
19381938

19391939
FloatPoint : NUMBER DOT NUMBER
19401940
{ char floatstring[256];
1941-
sprintf(floatstring, "%" PRId64 ".%" PRId64, $1, $3);
1941+
sprintf_s(floatstring, sizeof(floatstring), "%" PRId64 ".%" PRId64, $1, $3);
19421942
$$ = atof(floatstring);
19431943
}
19441944
| FLOATINGPOINT

0 commit comments

Comments
 (0)