optimisations/fixes from cppcheck
parent
8694edb1b6
commit
71f13a7c9a
|
@ -90,12 +90,12 @@ bool User::canAccess( int monitor_id ) {
|
|||
User *zmLoadUser( const char *username, const char *password ) {
|
||||
char sql[ZM_SQL_SML_BUFSIZ] = "";
|
||||
char safer_username[65]; // current db username size is 32
|
||||
char safer_password[129]; // current db password size is 64
|
||||
|
||||
// According to docs, size of safer_whatever must be 2*length+1 due to unicode conversions + null terminator.
|
||||
mysql_real_escape_string(&dbconn, safer_username, username, strlen( username ) );
|
||||
|
||||
if ( password ) {
|
||||
char safer_password[129]; // current db password size is 64
|
||||
mysql_real_escape_string(&dbconn, safer_password, password, strlen( password ) );
|
||||
snprintf( sql, sizeof(sql), "select Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds from Users where Username = '%s' and Password = password('%s') and Enabled = 1", safer_username, safer_password );
|
||||
} else {
|
||||
|
|
|
@ -80,7 +80,7 @@ const std::string stringtf( const char *format, ... )
|
|||
return( tempString );
|
||||
}
|
||||
|
||||
const std::string stringtf( const std::string &format, ... )
|
||||
const std::string stringtf( const std::string format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
char tempBuffer[8192];
|
||||
|
@ -100,7 +100,7 @@ bool startsWith( const std::string &haystack, const std::string &needle )
|
|||
return( haystack.substr( 0, needle.length() ) == needle );
|
||||
}
|
||||
|
||||
StringVector split( const std::string &string, const std::string chars, int limit )
|
||||
StringVector split( const std::string &string, const std::string &chars, int limit )
|
||||
{
|
||||
StringVector stringVector;
|
||||
std::string tempString = string;
|
||||
|
@ -134,7 +134,7 @@ StringVector split( const std::string &string, const std::string chars, int limi
|
|||
return( stringVector );
|
||||
}
|
||||
|
||||
const std::string join(const StringVector v, const char * delim ) {
|
||||
const std::string join(const StringVector &v, const char * delim ) {
|
||||
std::stringstream ss;
|
||||
|
||||
for(size_t i = 0; i < v.size(); ++i) {
|
||||
|
|
|
@ -33,11 +33,11 @@ std::string trimSet(std::string str, std::string trimset);
|
|||
std::string replaceAll(std::string str, std::string from, std::string to);
|
||||
|
||||
const std::string stringtf( const char *format, ... );
|
||||
const std::string stringtf( const std::string &format, ... );
|
||||
const std::string stringtf( const std::string format, ... );
|
||||
|
||||
bool startsWith( const std::string &haystack, const std::string &needle );
|
||||
StringVector split( const std::string &string, const std::string chars, int limit=0 );
|
||||
const std::string join( const StringVector, const char * );
|
||||
StringVector split( const std::string &string, const std::string &chars, int limit=0 );
|
||||
const std::string join( const StringVector &, const char * );
|
||||
|
||||
const std::string base64Encode( const std::string &inString );
|
||||
|
||||
|
|
Loading…
Reference in New Issue