From 7d7249f328786b35ee91c635c3dd75a1e2e53324 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 26 Apr 2016 15:48:21 -0400 Subject: [PATCH] use std::string instead of C strings. Mostly this will quiet build warnings on FreeBSD and removes the potential for buffer overflows --- src/zmu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/zmu.cpp b/src/zmu.cpp index a1e8887bd..3680c468a 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -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 ) );