Skip to content

Commit 599883a

Browse files
committed
validating url
1 parent e0de583 commit 599883a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/http/HttpResponse.h>
1111
#include <aws/core/utils/logging/LogMacros.h>
1212
#include <aws/core/utils/ARN.h>
13+
#include <aws/core/utils/DNS.h>
1314
#include <aws/core/utils/StringUtils.h>
1415
#include <aws/core/utils/HashingUtils.h>
1516
#include <aws/core/platform/Environment.h>
@@ -550,6 +551,16 @@ namespace Aws
550551
{
551552
ss << ".cn";
552553
}
554+
555+
Aws::Http::URI uri(ss.str());
556+
if (!Aws::Utils::IsValidHost(uri.GetHost()))
557+
{
558+
AWS_LOGSTREAM_ERROR(STS_RESOURCE_CLIENT_LOG_TAG,
559+
"Invalid endpoint host constructed: " << uri.GetHost());
560+
m_endpoint.clear();
561+
return;
562+
}
563+
553564
m_endpoint = ss.str();
554565

555566
AWS_LOGSTREAM_INFO(STS_RESOURCE_CLIENT_LOG_TAG, "Creating STS ResourceClient with endpoint: " << m_endpoint);
@@ -685,6 +696,16 @@ namespace Aws
685696
{
686697
ss << ".cn";
687698
}
699+
ss.str();
700+
701+
Aws::Http::URI uri(ss.str());
702+
if (!Aws::Utils::IsValidHost(uri.GetHost()))
703+
{
704+
AWS_LOGSTREAM_ERROR(SSO_RESOURCE_CLIENT_LOG_TAG,
705+
"Invalid endpoint host constructed: " << uri.GetHost());
706+
return {};
707+
}
708+
688709
return ss.str();
689710
}
690711

0 commit comments

Comments
 (0)