From c34b2e744cdaa06ec0306d206dcb8637225b8681 Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Tue, 22 Sep 2015 13:45:53 -0700 Subject: [PATCH] Do not use string_ref for output params. It is very much unsafe to do so as the string_ref could point on a stack variable of the callee. --- include/grpc++/security/auth_metadata_processor.h | 2 +- test/cpp/end2end/end2end_test.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/grpc++/security/auth_metadata_processor.h b/include/grpc++/security/auth_metadata_processor.h index 18ad9223217..9b9c06e3b63 100644 --- a/include/grpc++/security/auth_metadata_processor.h +++ b/include/grpc++/security/auth_metadata_processor.h @@ -45,7 +45,7 @@ namespace grpc { class AuthMetadataProcessor { public: typedef std::multimap InputMetadata; - typedef std::multimap OutputMetadata; + typedef std::multimap OutputMetadata; virtual ~AuthMetadataProcessor() {} diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 10a4c5ac26c..f732b99cad8 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -136,9 +136,9 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { if (auth_md_value.ends_with(kGoodGuy)) { context->AddProperty(kIdentityPropName, kGoodGuy); context->SetPeerIdentityPropertyName(kIdentityPropName); - consumed_auth_metadata->insert( - std::make_pair(string(auth_md->first.data(), auth_md->first.length()), - auth_md->second)); + consumed_auth_metadata->insert(std::make_pair( + string(auth_md->first.data(), auth_md->first.length()), + string(auth_md->second.data(), auth_md->second.length()))); return Status::OK; } else { return Status(StatusCode::UNAUTHENTICATED,