@@ -2291,7 +2291,8 @@ int ha_sphinx::HandleMysqlError ( MYSQL * pConn, int iErrCode )
2291
2291
CSphSEThreadTable * pTable = GetTls ();
2292
2292
if ( pTable )
2293
2293
{
2294
- strncpy ( pTable->m_tStats .m_sLastMessage , mysql_error ( pConn ), sizeof ( pTable->m_tStats .m_sLastMessage ) );
2294
+ strncpy ( pTable->m_tStats .m_sLastMessage , mysql_error ( pConn ), sizeof pTable->m_tStats .m_sLastMessage - 1 );
2295
+ pTable->m_tStats .m_sLastMessage [sizeof pTable->m_tStats .m_sLastMessage - 1 ] = ' \0 ' ;
2295
2296
pTable->m_tStats .m_bLastError = true ;
2296
2297
}
2297
2298
@@ -2558,7 +2559,8 @@ bool ha_sphinx::UnpackSchema ()
2558
2559
CSphSEThreadTable * pTable = GetTls ();
2559
2560
if ( pTable )
2560
2561
{
2561
- strncpy ( pTable->m_tStats .m_sLastMessage , sMessage , sizeof (pTable->m_tStats .m_sLastMessage ) );
2562
+ strncpy ( pTable->m_tStats .m_sLastMessage , sMessage , sizeof pTable->m_tStats .m_sLastMessage - 1 );
2563
+ pTable->m_tStats .m_sLastMessage [sizeof pTable->m_tStats .m_sLastMessage - 1 ] = ' \0 ' ;
2562
2564
pTable->m_tStats .m_bLastError = ( uStatus==SEARCHD_ERROR );
2563
2565
}
2564
2566
@@ -2982,7 +2984,8 @@ int ha_sphinx::index_read ( byte * buf, const byte * key, uint key_len, enum ha_
2982
2984
SPH_RET ( HA_ERR_END_OF_FILE );
2983
2985
}
2984
2986
2985
- strncpy ( pTable->m_tStats .m_sLastMessage , sMessage , sizeof (pTable->m_tStats .m_sLastMessage ) );
2987
+ strncpy ( pTable->m_tStats .m_sLastMessage , sMessage , sizeof pTable->m_tStats .m_sLastMessage - 1 );
2988
+ pTable->m_tStats .m_sLastMessage [sizeof pTable->m_tStats .m_sLastMessage - 1 ] = ' \0 ' ;
2986
2989
SafeDeleteArray ( sMessage );
2987
2990
2988
2991
if ( uRespStatus!=SEARCHD_WARNING )
0 commit comments