Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Add guard for long hostnames.

Kishore Nallan6e2931bd020e
diff --git a/src/raft_server.cpp b/src/raft_server.cpp
index 26cf6396..94f0465c 100644
--- a/src/raft_server.cpp
+++ b/src/raft_server.cpp
@@ -163,6 +163,12 @@ string ReplicationState::resolve_node_hosts(const string& nodes_config) {
continue;
}
+ if(node_parts[0].size() > 64) {
+ LOG(ERROR) << "Host name is too long (must be < 64 characters): " << node_parts[0];
+ final_nodes_vec.emplace_back("");
+ continue;
+ }
+
butil::ip_t ip;
int status = butil::hostname2ip(node_parts[0].c_str(), &ip);
diff --git a/test/raft_server_test.cpp b/test/raft_server_test.cpp
index 79bfbf31..45997923 100644
--- a/test/raft_server_test.cpp
+++ b/test/raft_server_test.cpp
@@ -11,4 +11,9 @@ TEST(RaftServerTest, ResolveNodesConfigWithHostNames) {
ASSERT_EQ("localhost:8107:8108localhost:7107:7108,127.0.0.1:6107:6108",
ReplicationState::resolve_node_hosts("localhost:8107:8108localhost:7107:7108,localhost:6107:6108"));
+
+ // hostname must be less than 64 chars
+ ASSERT_EQ("",
+ ReplicationState::resolve_node_hosts("typesense-node-2.typesense-service.typesense-"
+ "namespace.svc.cluster.local:6107:6108"));
}
\ No newline at end of file