[ssl] Fix for ALPN comparision logic (#35863)

fix for b/316952851

Closes #35863

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35863 from erm-g:apln-calc 1b445bf14a
PiperOrigin-RevId: 605697428
pull/35809/head
erm-g 10 months ago committed by Copybara-Service
parent 4cbe274f4b
commit 3343756673
  1. 5
      src/core/ext/transport/chttp2/alpn/alpn.cc
  2. 1
      test/core/transport/chttp2/alpn_test.cc

@ -30,7 +30,10 @@ static const char* const supported_versions[] = {"h2"};
int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size) {
size_t i;
for (i = 0; i < GPR_ARRAY_SIZE(supported_versions); i++) {
if (!strncmp(version, supported_versions[i], size)) return 1;
if (size == strlen(supported_versions[i]) &&
!strncmp(version, supported_versions[i], size)) {
return 1;
}
}
return 0;
}

@ -32,6 +32,7 @@ TEST(AlpnTest, TestAlpnFailure) {
ASSERT_FALSE(grpc_chttp2_is_alpn_version_supported("h2-155", 6));
ASSERT_FALSE(grpc_chttp2_is_alpn_version_supported("h1-15", 5));
ASSERT_FALSE(grpc_chttp2_is_alpn_version_supported("grpc-exp", 8));
ASSERT_FALSE(grpc_chttp2_is_alpn_version_supported("h", 1));
}
int main(int argc, char** argv) {

Loading…
Cancel
Save