diff options
author | Dan Rosart <Torgen@users.noreply.github.com> | 2018-06-26 23:56:43 -0700 |
---|---|---|
committer | Dan Rosart <torgen@google.com> | 2018-07-03 13:13:37 -0700 |
commit | 477a1aec5a222e04555113b2e0b38ddfdc463933 (patch) | |
tree | 2bfc11e503c7938de20093008fc2bee573297554 /test/core/security | |
parent | bca3d3a6d09bd6fdc3dfa46c6d980a8d1fef37b0 (diff) |
Don't segfault when product name from BIOS is empty
Somehow some Dell servers we're trying to run a gRPC client on have an empty product name in the BIOS. When gRPC tries to creadte default credentials, it checks whether it's running on GCE by strcmp()ing the contents of /sys/class/dmi/id/product_name to some magic strings. When it reads that file, it gets only a newline; in trim() it skips over the newline in both directions, and since end < start it returns nullptr. This causes a segfault in the strcmp() call. Since a machine without a product name clearly isn't GCE, change it to return false instead.
Diffstat (limited to 'test/core/security')
-rw-r--r-- | test/core/security/check_gcp_environment_linux_test.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/test/core/security/check_gcp_environment_linux_test.cc b/test/core/security/check_gcp_environment_linux_test.cc index 3acd5b6ae4..b01471abd3 100644 --- a/test/core/security/check_gcp_environment_linux_test.cc +++ b/test/core/security/check_gcp_environment_linux_test.cc @@ -69,6 +69,7 @@ static void test_gcp_environment_check_failure() { GPR_ASSERT(!check_bios_data_linux_test("Amazon")); GPR_ASSERT(!check_bios_data_linux_test("Google-Chrome\t\t")); GPR_ASSERT(!check_bios_data_linux_test("Amazon")); + GPR_ASSERT(!check_bios_data_linux_test("\n")); } int main(int argc, char** argv) { |