fix [-Wstringop-truncation]

This commit is contained in:
Garux 2021-01-01 18:05:09 +03:00
parent 155d633ae9
commit ba1a1b64f6
2 changed files with 14 additions and 7 deletions

View File

@ -160,7 +160,8 @@ void DTrainDrawer::renderWireframe( Renderer& renderer, const VolumeTest& volume
void AddSplineControl( const char* control, splinePoint_t* pSP ) {
controlPoint_t cp;
strncpy( cp.strName, control, 64 );
strncpy( cp.strName, control, sizeof( cp.strName ) - 1 );
cp.strName[ sizeof( cp.strName ) - 1 ] = '\0';
pSP->m_pointList.push_front( cp );
}
@ -297,7 +298,8 @@ void DTrainDrawer::BuildPaths() {
void DTrainDrawer::AddControlPoint( const char* name, vec_t* origin ){
controlPoint_t* pCP = new controlPoint_t;
strncpy( pCP->strName, name, 64 );
strncpy( pCP->strName, name, sizeof( pCP->strName ) - 1 );
pCP->strName[ sizeof( pCP->strName ) - 1 ] = '\0';
VectorCopy( origin, pCP->vOrigin );
m_pointList.push_back( pCP );
@ -306,8 +308,10 @@ void DTrainDrawer::AddControlPoint( const char* name, vec_t* origin ){
splinePoint_t* DTrainDrawer::AddSplinePoint( const char* name, const char* target, vec_t* origin ){
splinePoint_t* pSP = new splinePoint_t;
strncpy( pSP->point.strName, name, 64 );
strncpy( pSP->strTarget, target, 64 );
strncpy( pSP->point.strName, name, sizeof( pSP->point.strName ) - 1 );
pSP->point.strName[ sizeof( pSP->point.strName ) - 1 ] = '\0';
strncpy( pSP->strTarget, target, sizeof( pSP->strTarget ) - 1 );
pSP->strTarget[ sizeof( pSP->strTarget ) - 1 ] = '\0';
VectorCopy( origin, pSP->point.vOrigin );
m_splineList.push_back( pSP );

View File

@ -122,19 +122,22 @@ void ReadConfig( CScriptParser* pScriptParser ) {
GT; CT;
strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
strncpy( m_trees[m_numModels++].name, pToken, sizeof( m_trees[m_numModels].name ) - 1 );
m_trees[m_numModels].name[ sizeof( m_trees[m_numModels].name ) - 1 ] = '\0';
}
else if ( MT( "link" ) ) {
GT; CT;
strncpy( m_linkName, pToken, MAX_QPATH );
strncpy( m_linkName, pToken, sizeof( m_linkName ) - 1 );
m_linkName[ sizeof( m_linkName ) - 1 ] = '\0';
m_autoLink = true;
}
else if ( MT( "entity" ) ) {
GT; CT;
strncpy( m_entType, pToken, MAX_QPATH );
strncpy( m_entType, pToken, sizeof( m_entType ) - 1 );
m_entType[ sizeof( m_entType ) - 1 ] = '\0';
}
else if ( MT( "offset" ) ) {
GT; CT;