Skip to content

Commit

Permalink
Merge "Make sure substr is invoked with pos less than string length."…
Browse files Browse the repository at this point in the history
… into R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 1, 2016
2 parents f105043 + 3206d5e commit 1da98c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/http/http_session.cc
Expand Up @@ -155,7 +155,6 @@ class HttpSession::RequestHandler : public Task {
}

void NotFound(HttpSession *session, const HttpRequest *request) {
string url = request->UrlPath().substr(1);
static const char no_response[] =
"HTTP/1.1 404 Not Found\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
Expand Down
10 changes: 5 additions & 5 deletions src/vnsw/agent/oper/vn.cc
Expand Up @@ -201,12 +201,12 @@ bool VnEntry::GetPrefix(const Ip6Address &ip, Ip6Address *prefix,
std::string VnEntry::GetProject() const {
// TODO: update to get the project name from project-vn link.
// Currently, this info doesnt come to the agent
std::size_t start_pos = name_.find(":") + 1;
std::size_t end_pos = name_.find(":", start_pos);
if (end_pos == std::string::npos)
std::string name(name_.c_str());
char *saveptr;
if (strtok_r(const_cast<char *>(name.c_str()), ":", &saveptr) == NULL)
return "";

return name_.substr(start_pos, end_pos - start_pos);
char *project = strtok_r(NULL, ":", &saveptr);
return (project == NULL) ? "" : std::string(project);
}

int VnEntry::GetVxLanId() const {
Expand Down
4 changes: 3 additions & 1 deletion src/vnsw/agent/services/metadata_proxy.cc
Expand Up @@ -171,7 +171,9 @@ MetadataProxy::HandleMetadataRequest(HttpSession *session, const HttpRequest *re
header_options.push_back(std::string("X-Instance-ID-Signature: " +
signature));

std::string uri = request->UrlPath().substr(1); // ignore the first "/"
std::string uri = request->UrlPath();
if (uri.size())
uri = uri.substr(1); // ignore the first "/"
const std::string &body = request->Body();
{
HttpConnection *conn = GetProxyConnection(session, conn_close);
Expand Down

0 comments on commit 1da98c4

Please sign in to comment.