Skip to content

Commit

Permalink
Merge pull request grpc#15929 from Torgen/empty_product_name_segfault
Browse files Browse the repository at this point in the history
Don't segfault when product name from BIOS is empty
  • Loading branch information
nicolasnoble authored Jul 21, 2018
2 parents dbc1e27 + d4c9867 commit 2cfc216
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ namespace internal {

bool check_bios_data(const char* bios_data_file) {
char* bios_data = read_bios_file(bios_data_file);
bool result = (!strcmp(bios_data, GRPC_ALTS_EXPECT_NAME_GOOGLE)) ||
(!strcmp(bios_data, GRPC_ALTS_EXPECT_NAME_GCE));
bool result =
bios_data && ((!strcmp(bios_data, GRPC_ALTS_EXPECT_NAME_GOOGLE)) ||
(!strcmp(bios_data, GRPC_ALTS_EXPECT_NAME_GCE)));
gpr_free(bios_data);
return result;
}
Expand Down
1 change: 1 addition & 0 deletions test/core/security/check_gcp_environment_linux_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2cfc216

Please sign in to comment.