summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2017-01-12 14:39:56 -0500
committerBernard Normier <bernard@zeroc.com>2017-01-12 14:39:56 -0500
commit21d56ef199fe0002c90b57d873878ac9ba4a32e1 (patch)
treea39441e45379a574beb6563cb5b5c34cdcdf5cb1 /cpp
parentRevert "Replaced Borders by Paddings to eliminate deprecation warnings" (diff)
downloadice-21d56ef199fe0002c90b57d873878ac9ba4a32e1.tar.bz2
ice-21d56ef199fe0002c90b57d873878ac9ba4a32e1.tar.xz
ice-21d56ef199fe0002c90b57d873878ac9ba4a32e1.zip
Reject empty endpoint in OA endpoint list
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp11
-rw-r--r--cpp/test/Ice/proxy/AllTests.cpp34
2 files changed, 38 insertions, 7 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index df7b4a81a77..e3b9cb2450c 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -1194,6 +1194,10 @@ Ice::ObjectAdapterI::parseEndpoints(const string& endpts, bool oaEndpoints) cons
beg = endpts.find_first_not_of(delim, end);
if(beg == string::npos)
{
+ if(!endpoints.empty())
+ {
+ throw EndpointParseException(__FILE__, __LINE__, "invalid empty object adapter endpoint");
+ }
break;
}
@@ -1242,17 +1246,14 @@ Ice::ObjectAdapterI::parseEndpoints(const string& endpts, bool oaEndpoints) cons
if(end == beg)
{
- ++end;
- continue;
+ throw EndpointParseException(__FILE__, __LINE__, "invalid empty object adapter endpoint");
}
string s = endpts.substr(beg, end - beg);
EndpointIPtr endp = _instance->endpointFactoryManager()->create(s, oaEndpoints);
if(endp == 0)
{
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid object adapter endpoint `" + s + "'";
- throw ex;
+ throw EndpointParseException(__FILE__, __LINE__, "invalid object adapter endpoint `" + s + "'");
}
endpoints.push_back(endp);
diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp
index 269988a9119..82655d278e5 100644
--- a/cpp/test/Ice/proxy/AllTests.cpp
+++ b/cpp/test/Ice/proxy/AllTests.cpp
@@ -236,7 +236,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
- b1 = communicator->stringToProxy("test:tcp@adapterId");
+ communicator->stringToProxy("test:tcp@adapterId");
test(false);
}
catch(const Ice::EndpointParseException&)
@@ -254,7 +254,37 @@ allTests(const Ice::CommunicatorPtr& communicator)
//}
try
{
- b1 = communicator->stringToProxy("test::tcp");
+ communicator->stringToProxy("test: :tcp");
+ test(false);
+ }
+ catch(const Ice::EndpointParseException&)
+ {
+ }
+
+ //
+ // Test invalid endpoint syntax
+ //
+ try
+ {
+ communicator->createObjectAdapterWithEndpoints("BadAdapter", " : ");
+ test(false);
+ }
+ catch(const Ice::EndpointParseException&)
+ {
+ }
+
+ try
+ {
+ communicator->createObjectAdapterWithEndpoints("BadAdapter", "tcp: ");
+ test(false);
+ }
+ catch(const Ice::EndpointParseException&)
+ {
+ }
+
+ try
+ {
+ communicator->createObjectAdapterWithEndpoints("BadAdapter", ":tcp");
test(false);
}
catch(const Ice::EndpointParseException&)