From 81e718ab513e2cdf1b1e22b268c5798752d79cc1 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Sat, 9 Oct 2010 15:46:40 +0000 Subject: server: parse more precisely when validating auth options Signed-off-by: Csaba Henk Signed-off-by: Anand V. Avati BUG: 1885 (auth validator in server parses too sloppily) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1885 --- xlators/protocol/server/src/server.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 85abfb54d2a..6c763e7fbbf 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -340,36 +340,32 @@ out: int validate_auth_options (xlator_t *this, dict_t *dict) { - int ret = -1; int error = 0; xlator_list_t *trav = NULL; data_pair_t *pair = NULL; - char *saveptr = NULL; - char *tmp = NULL; - char *key_cpy = NULL; + char *tail = NULL; trav = this->children; while (trav) { error = -1; for (pair = dict->members_list; pair; pair = pair->next) { - key_cpy = gf_strdup (pair->key); - tmp = strtok_r (key_cpy, ".", &saveptr); - ret = strcmp (tmp, "auth"); - if (ret == 0) { - /* for module type */ - tmp = strtok_r (NULL, ".", &saveptr); - if (!tmp) - break; - /* for volume name */ - tmp = strtok_r (NULL, ".", &saveptr); - } - - if (strcmp (tmp, trav->xlator->name) == 0) { + tail = strtail (pair->key, "auth."); + if (!tail) + continue; + /* fast fwd thru module type */ + tail = strchr (tail, '.'); + if (!tail) + continue; + tail++; + + tail = strtail (tail, trav->xlator->name); + if (!tail) + continue; + + if (*tail == '.') { error = 0; - GF_FREE (key_cpy); break; } - GF_FREE (key_cpy); } if (-1 == error) { gf_log (this->name, GF_LOG_ERROR, -- cgit