Safer_username and safer_login should be based on the username and login (#2482)
(lengths * 2)+1. Control input lengths at user input
This commit is contained in:
parent
99a6db3994
commit
a81e7c5221
|
@ -89,13 +89,13 @@ bool User::canAccess( int monitor_id ) {
|
||||||
// Please note that in auth relay mode = none, password is NULL
|
// Please note that in auth relay mode = none, password is NULL
|
||||||
User *zmLoadUser( const char *username, const char *password ) {
|
User *zmLoadUser( const char *username, const char *password ) {
|
||||||
char sql[ZM_SQL_MED_BUFSIZ] = "";
|
char sql[ZM_SQL_MED_BUFSIZ] = "";
|
||||||
char safer_username[65]; // current db username size is 32
|
char *safer_username = new char[(strlen(username) * 2) + 1];
|
||||||
|
|
||||||
// According to docs, size of safer_whatever must be 2*length+1 due to unicode conversions + null terminator.
|
// 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 ) );
|
mysql_real_escape_string(&dbconn, safer_username, username, strlen( username ) );
|
||||||
|
|
||||||
if ( password ) {
|
if ( password ) {
|
||||||
char safer_password[129]; // current db password size is 64
|
char *safer_password = new char[(strlen(password) * 2) +1];
|
||||||
mysql_real_escape_string(&dbconn, safer_password, password, strlen( password ) );
|
mysql_real_escape_string(&dbconn, safer_password, password, strlen( password ) );
|
||||||
snprintf(sql, sizeof(sql),
|
snprintf(sql, sizeof(sql),
|
||||||
"SELECT Id, Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds"
|
"SELECT Id, Username, Password, Enabled, Stream+0, Events+0, Control+0, Monitors+0, System+0, MonitorIds"
|
||||||
|
|
Loading…
Reference in New Issue