use std::string instead of C strings. Mostly this will quiet build warnings on FreeBSD and removes the potential for buffer overflows

This commit is contained in:
Isaac Connor 2016-04-26 15:48:21 -04:00
parent fe9cb4b7ec
commit 7d7249f328
1 changed files with 4 additions and 5 deletions

View File

@ -757,15 +757,14 @@ int main( int argc, char *argv[] )
if ( function & ZMU_LIST )
{
char sql[ZM_SQL_SML_BUFSIZ];
strncpy( sql, "select Id, Function+0 from Monitors", sizeof(sql) );
std::string sql = "select Id, Function+0 from Monitors";
if ( !verbose )
{
strncat( sql, " where Function != 'None'", sizeof(sql)-strlen(sql) );
sql += "where Function != 'None'";
}
strncat( sql, " order by Id asc", sizeof(sql)-strlen(sql) );
sql += " order by Id asc";
if ( mysql_query( &dbconn, sql ) )
if ( mysql_query( &dbconn, sql.c_str() ) )
{
Error( "Can't run query: %s", mysql_error( &dbconn ) );
exit( mysql_errno( &dbconn ) );