From bcfc2dbeb159aa1d2443e804e4fc496eac8ab9ba Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 8 Oct 2012 16:28:03 -0500 Subject: [PATCH] we do want this one bit from the last patch --- src/switch_core_sqldb.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index b679baab0c..bb82202fbc 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -2818,8 +2818,13 @@ SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream) switch_mutex_lock(sql_manager.dbh_mutex); for (dbh = sql_manager.handle_pool; dbh; dbh = dbh->next) { - char *needle = "pass=\""; + char *needles[3]; time_t diff = 0; + int i = 0; + + needles[0] = "pass=\""; + needles[1] = "password="; + needles[2] = "password='"; diff = now - dbh->last_used; @@ -2832,11 +2837,26 @@ SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream) /* sanitize password */ memset(cleankey_str, 0, sizeof(cleankey_str)); - pos1 = strstr(dbh->name, needle) + strlen(needle); - pos2 = strstr(pos1, "\""); - strncpy(cleankey_str, dbh->name, pos1 - dbh->name); - strcpy(&cleankey_str[pos1 - dbh->name], pos2); - + for (i = 0; i < 3; i++) { + if((pos1 = strstr(dbh->name, needles[i]))) { + pos1 += strlen(needles[i]); + + if (!(pos2 = strstr(pos1, "\""))) { + if (!(pos2 = strstr(pos1, "'"))) { + if (!(pos2 = strstr(pos1, " "))) { + pos2 = pos1 + strlen(pos1); + } + } + } + strncpy(cleankey_str, dbh->name, pos1 - dbh->name); + strcpy(&cleankey_str[pos1 - dbh->name], pos2); + break; + } + } + if (i == 3) { + strncpy(cleankey_str, dbh->name, strlen(dbh->name)); + } + count++; if (dbh->use_count) {