summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-02-18 01:27:31 +0000
committerAnand V. Avati <avati@dev.gluster.com>2011-02-22 02:10:55 -0800
commitea0634bf88dd63294559c2e4542b73b772b7ec56 (patch)
treea0faa879a9fa370b5d48ca696eb4c795bf7cc961 /cli/src
parent2795f3e03a299daf88e3172b068511d41c493247 (diff)
Validate peer probe command's hostname/ip address.
Note, if an ip octet range exceeds 255, though this fails as a valid ipv4 address, it is still a valid hostname. valid chars are: 'a'-'z', '0' - '9', '-', '.' with a max of 255 chars. Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 2194 (gluster peer probe on a ip octet value bigger than 255 has no validation) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2194
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-peer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index ca89592d613..0c4d54dc155 100644
--- a/cli/src/cli-cmd-peer.c
+++ b/cli/src/cli-cmd-peer.c
@@ -71,6 +71,14 @@ cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (ret)
goto out;
+ ret = valid_internet_address ((char *) words[2]);
+ if (ret == 1) {
+ ret = 0;
+ } else {
+ cli_usage_out (word->pattern);
+ parse_error = 1;
+ goto out;
+ }
/* if (words[3]) {
ret = dict_set_str (dict, "port", (char *)words[3]);
if (ret)
goto check_failed; ai_list_tmp1->info = ai_info; list_add_tail (&ai_list_tmp1->list, &ai_list->list); ai_list_tmp1 = NULL; } i = 0; ai_list_tmp1 = list_entry (ai_list->list.next, addrinfo_list_t, list); /* Check for bad brick order */ while (i < brick_count) { ++i; ai_info = ai_list_tmp1->info; ai_list_tmp1 = list_entry (ai_list_tmp1->list.next, addrinfo_list_t, list); if ( 0 == i % sub_count) { j = 0; continue; } ai_list_tmp2 = ai_list_tmp1; k = j; while (k < sub_count - 1) { ++k; ret = cli_cmd_compare_addrinfo (ai_info, ai_list_tmp2->info); if (GF_AI_COMPARE_ERROR == ret) goto check_failed; if (GF_AI_COMPARE_MATCH == ret) goto found_bad_brick_order; ai_list_tmp2 = list_entry (ai_list_tmp2->list.next, addrinfo_list_t, list); } ++j; } gf_log ("cli", GF_LOG_INFO, "Brick order okay"); ret = 0; goto out; check_failed: gf_log ("cli", GF_LOG_INFO, "Failed bad brick order check"); answer = cli_cmd_get_confirmation(state, failed_question); if (GF_ANSWER_YES == answer) ret = 0; goto out; found_bad_brick_order: gf_log ("cli", GF_LOG_INFO, "Bad brick order found"); answer = cli_cmd_get_confirmation (state, found_question); if (GF_ANSWER_YES == answer) ret = 0; out: ai_list_tmp2 = NULL; i = 0; GF_FREE (brick_list_dup); list_for_each_entry (ai_list_tmp1, &ai_list->list, list) { if (ai_list_tmp1->info) freeaddrinfo (ai_list_tmp1->info); free (ai_list_tmp2); ai_list_tmp2 = ai_list_tmp1; } free (ai_list_tmp2); return ret; } int cli_cmd_volume_create_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) {