From 21df8d1346a3eb19717071d0606b7ea25b05ca84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 5 Sep 2017 14:53:15 +0200 Subject: [PATCH] Return 0 checksum if mysql_users is empty If table `mysql_users` is empty, its checksum must be all zeros --- lib/MySQL_Authentication.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/MySQL_Authentication.cpp b/lib/MySQL_Authentication.cpp index 4a860de3e..eab69a8ad 100644 --- a/lib/MySQL_Authentication.cpp +++ b/lib/MySQL_Authentication.cpp @@ -484,20 +484,27 @@ uint64_t MySQL_Authentication::_get_runtime_checksum(enum cred_username_type use if (cg.bt_map.size() == 0) { return 0; } + bool foundany = false; SpookyHash myhash; myhash.Init(13,4); for (it = cg.bt_map.begin(); it != cg.bt_map.end(); ) { account_details_t *ad=it->second; - myhash.Update(&ad->use_ssl,sizeof(ad->use_ssl)); - myhash.Update(&ad->default_hostgroup,sizeof(ad->default_hostgroup)); - myhash.Update(&ad->schema_locked,sizeof(ad->schema_locked)); - myhash.Update(&ad->transaction_persistent,sizeof(ad->transaction_persistent)); - myhash.Update(&ad->fast_forward,sizeof(ad->fast_forward)); - myhash.Update(&ad->max_connections,sizeof(ad->max_connections)); - myhash.Update(ad->username,strlen(ad->username)); - myhash.Update(ad->password,strlen(ad->password)); + if (ad->default_hostgroup >= 0) { + foundany = true; + myhash.Update(&ad->use_ssl,sizeof(ad->use_ssl)); + myhash.Update(&ad->default_hostgroup,sizeof(ad->default_hostgroup)); + myhash.Update(&ad->schema_locked,sizeof(ad->schema_locked)); + myhash.Update(&ad->transaction_persistent,sizeof(ad->transaction_persistent)); + myhash.Update(&ad->fast_forward,sizeof(ad->fast_forward)); + myhash.Update(&ad->max_connections,sizeof(ad->max_connections)); + myhash.Update(ad->username,strlen(ad->username)); + myhash.Update(ad->password,strlen(ad->password)); + } it++; } + if (foundany == false) { + return 0; + } uint64_t hash1, hash2; myhash.Final(&hash1, &hash2); return hash1;