mirror of https://github.com/grpc/grpc.git
Merge pull request #20109 from veblush/smetadata
Fix buffer-overflow in grpc_static_mdelem_for_static_stringspull/20160/head
commit
1168c903c1
4 changed files with 67 additions and 8 deletions
@ -0,0 +1,51 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2019 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
#include <gtest/gtest.h> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/transport/metadata.h" |
||||
#include "src/core/lib/transport/static_metadata.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
namespace grpc_core { |
||||
namespace { |
||||
|
||||
TEST(StaticMetadataTest, ReadAllStaticElements) { |
||||
// This makes sure that all static elements are returned when
|
||||
// grpc_mdelem_from_slices is called with key pairs pregenerated.
|
||||
for (int i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) { |
||||
const grpc_mdelem mdelem = grpc_static_mdelem_manifested()[i]; |
||||
const grpc_mdelem mdelem2 = |
||||
grpc_mdelem_from_slices(GRPC_MDKEY(mdelem), GRPC_MDVALUE(mdelem)); |
||||
EXPECT_EQ(mdelem.payload, mdelem2.payload); |
||||
} |
||||
} |
||||
|
||||
} // namespace
|
||||
} // namespace grpc_core
|
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc_init(); |
||||
grpc::testing::TestEnvironment env(argc, argv); |
||||
::testing::InitGoogleTest(&argc, argv); |
||||
int retval = RUN_ALL_TESTS(); |
||||
grpc_shutdown(); |
||||
return retval; |
||||
} |
Loading…
Reference in new issue