Use strncpy
Use strncpy instead of strcpy to ensure the arrays will not be overflowered. Only copy one less than size of char array to leave a NUL character at the end even if the copy is truncated provided the original object is zeroed memory. Change-Id: I00f7679630cf28dcb9a51cb0aba2810a4f4c72b9
이 커밋은 다음에 포함됨:
@@ -143,10 +143,10 @@ CALGSLDevice::getAttribs_int(gsl::gsCtx* cs)
|
||||
m_attribs.pciTopologyInformation = m_adp->getLocationId();
|
||||
|
||||
const uint8* boardName = cs->getString(GSL_GS_RENDERER);
|
||||
::strncpy(m_attribs.boardName, (char*)boardName, CAL_ASIC_INFO_MAX_LEN * sizeof(char));
|
||||
::strncpy(m_attribs.boardName, (char*)boardName, CAL_ASIC_INFO_MAX_LEN * sizeof(char) - 1);
|
||||
|
||||
const uint8* driverStore = cs->getString(GSL_GS_DRIVER_STORE_PATH);
|
||||
::strncpy(m_attribs.driverStore, (char*)driverStore, CAL_DRIVER_STORE_MAX_LEN * sizeof(char));
|
||||
::strncpy(m_attribs.driverStore, (char*)driverStore, CAL_DRIVER_STORE_MAX_LEN * sizeof(char) - 1);
|
||||
|
||||
m_attribs.counterFreq = cs->getCounterFreq();
|
||||
m_attribs.nanoSecondsPerTick = 1000000000.0 / cs->getCounterFreq();
|
||||
|
||||
@@ -62,7 +62,7 @@ getConfigFromFile(gslStaticRuntimeConfig& scfg,
|
||||
// Check if location string is longer than 128 then assign, if not default location will be C:\packet.txt in gsl_ctx.cpp: gsCtxManager::PacketDump()
|
||||
uintp length = commandbufferDumpFilename.length();
|
||||
if (length > 0 && length < sizeof(dcfg.CommandbufferDumpFilename))
|
||||
strcpy(dcfg.CommandbufferDumpFilename, commandbufferDumpFilename.c_str());
|
||||
::strncpy(dcfg.CommandbufferDumpFilename, commandbufferDumpFilename.c_str(), sizeof(dcfg.CommandbufferDumpFilename) - 1);
|
||||
|
||||
iniFile.getValue(section, CAL_ENABLEPATCHDUMP, (CALint*) &dcfg.nPatchDumpLevel.value);
|
||||
iniFile.getValue(section, CAL_ENABLEMACROTILE, (CALboolean*) ¯o);
|
||||
|
||||
새 이슈에서 참조
사용자 차단