Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 03/10] swim: validate URI in swim_probe_member()
Date: Wed, 15 May 2019 22:36:40 +0300	[thread overview]
Message-ID: <471b5dd2140756e7f9928e3ba6be48a898ad788f.1557948687.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1557948686.git.v.shpilevoy@tarantool.org>

Similar methods validate their arguments: add_member,
remove_member. Validate here as well for consistency.

Part of #3234
---
 src/lib/swim/swim.c   | 4 ++++
 test/unit/swim.c      | 3 ++-
 test/unit/swim.result | 7 ++++---
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index a9a0a39b3..fb2b1490b 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -1890,6 +1890,10 @@ int
 swim_probe_member(struct swim *swim, const char *uri)
 {
 	assert(swim_is_configured(swim));
+	if (uri == NULL) {
+		diag_set(SwimError, "swim.probe_member: URI is mandatory");
+		return -1;
+	}
 	struct sockaddr_in addr;
 	if (swim_uri_to_addr(uri, &addr, "swim.probe_member:") != 0)
 		return -1;
diff --git a/test/unit/swim.c b/test/unit/swim.c
index d9613e8e0..c6ef1eebc 100644
--- a/test/unit/swim.c
+++ b/test/unit/swim.c
@@ -359,12 +359,13 @@ swim_test_basic_gossip(void)
 static void
 swim_test_probe(void)
 {
-	swim_start_test(2);
+	swim_start_test(3);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 
 	struct swim *s1 = swim_cluster_member(cluster, 0);
 	struct swim *s2 = swim_cluster_member(cluster, 1);
 	const char *s2_uri = swim_member_uri(swim_self(s2));
+	is(swim_probe_member(s1, NULL), -1, "probe validates URI");
 	is(swim_probe_member(s1, s2_uri), 0, "send probe");
 	is(swim_cluster_wait_fullmesh(cluster, 0.1), 0,
 	   "receive ACK on probe and get fullmesh")
diff --git a/test/unit/swim.result b/test/unit/swim.result
index 266d83589..587f66c7a 100644
--- a/test/unit/swim.result
+++ b/test/unit/swim.result
@@ -78,9 +78,10 @@ ok 5 - subtests
 ok 6 - subtests
 	*** swim_test_basic_failure_detection: done ***
 	*** swim_test_probe ***
-    1..2
-    ok 1 - send probe
-    ok 2 - receive ACK on probe and get fullmesh
+    1..3
+    ok 1 - probe validates URI
+    ok 2 - send probe
+    ok 3 - receive ACK on probe and get fullmesh
 ok 7 - subtests
 	*** swim_test_probe: done ***
 	*** swim_test_refute ***
-- 
2.20.1 (Apple Git-117)

  parent reply	other threads:[~2019-05-15 19:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-15 19:36 [tarantool-patches] [PATCH 00/10] swim Lua API Vladislav Shpilevoy
2019-05-15 19:36 ` [tarantool-patches] [PATCH 01/10] swim: fix an assertion on attempt to chage timeouts Vladislav Shpilevoy
2019-05-16  7:28   ` [tarantool-patches] " Konstantin Osipov
2019-05-15 19:36 ` [tarantool-patches] [PATCH 10/10] swim: cache members in Lua member table Vladislav Shpilevoy
2019-05-16  7:31   ` [tarantool-patches] " Konstantin Osipov
2019-05-15 19:36 ` [tarantool-patches] [PATCH 02/10] swim: make swim_new_round() void Vladislav Shpilevoy
2019-05-16  7:31   ` [tarantool-patches] " Konstantin Osipov
2019-05-15 19:36 ` Vladislav Shpilevoy [this message]
2019-05-16  7:31   ` [tarantool-patches] Re: [PATCH 03/10] swim: validate URI in swim_probe_member() Konstantin Osipov
2019-05-15 19:36 ` [tarantool-patches] [PATCH 04/10] swim: introduce Lua interface Vladislav Shpilevoy
2019-05-15 19:36 ` [tarantool-patches] [PATCH 05/10] swim: Lua bindings to manipulate member table Vladislav Shpilevoy
2019-05-16  7:32   ` [tarantool-patches] " Konstantin Osipov
2019-05-15 19:36 ` [tarantool-patches] [PATCH 06/10] swim: Lua bindings to access individual members Vladislav Shpilevoy
2019-05-15 19:36 ` [tarantool-patches] [PATCH 07/10] swim: pairs() function to iterate over member table Vladislav Shpilevoy
2019-05-15 19:36 ` [tarantool-patches] [PATCH 08/10] swim: allow to use cdata struct tt_uuid in Lua API Vladislav Shpilevoy
2019-05-15 19:36 ` [tarantool-patches] [PATCH 09/10] swim: cache decoded payload in the Lua module Vladislav Shpilevoy
2019-05-16  7:36   ` [tarantool-patches] " Konstantin Osipov
2019-05-16 11:58     ` Vladislav Shpilevoy
2019-05-16 22:46     ` Vladislav Shpilevoy
2019-05-21 16:57 ` [tarantool-patches] Re: [PATCH 00/10] swim Lua API Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=471b5dd2140756e7f9928e3ba6be48a898ad788f.1557948687.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 03/10] swim: validate URI in swim_probe_member()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox