Ver código fonte

Fixing the SSL_REUSE auth context string attribute.

"true" and "false" are strings, so use similar code that of the cstring variant. Otherwise, the generated properties will have an embedded zero in there.
Nicolas "Pixel" Noble 7 anos atrás
pai
commit
71655cf48a

+ 2 - 2
src/core/tsi/ssl_transport_security.cc

@@ -1049,9 +1049,9 @@ static tsi_result ssl_handshaker_result_extract_peer(
   }
   }
 
 
   const char* session_reused = SSL_session_reused(impl->ssl) ? "true" : "false";
   const char* session_reused = SSL_session_reused(impl->ssl) ? "true" : "false";
-  result = tsi_construct_string_peer_property(
+  result = tsi_construct_string_peer_property_from_cstring(
       TSI_SSL_SESSION_REUSED_PEER_PROPERTY, session_reused,
       TSI_SSL_SESSION_REUSED_PEER_PROPERTY, session_reused,
-      strlen(session_reused) + 1, &peer->properties[peer->property_count]);
+      &peer->properties[peer->property_count]);
   if (result != TSI_OK) return result;
   if (result != TSI_OK) return result;
   peer->property_count++;
   peer->property_count++;
 
 

+ 4 - 2
test/core/tsi/ssl_transport_security_test.cc

@@ -208,9 +208,11 @@ static void check_session_reusage(ssl_tsi_test_fixture* ssl_fixture,
       tsi_peer_get_property_by_name(peer, TSI_SSL_SESSION_REUSED_PEER_PROPERTY);
       tsi_peer_get_property_by_name(peer, TSI_SSL_SESSION_REUSED_PEER_PROPERTY);
   GPR_ASSERT(session_reused != nullptr);
   GPR_ASSERT(session_reused != nullptr);
   if (ssl_fixture->session_reused) {
   if (ssl_fixture->session_reused) {
-    GPR_ASSERT(strcmp(session_reused->value.data, "true") == 0);
+    GPR_ASSERT(strncmp(session_reused->value.data, "true",
+                       session_reused->value.length) == 0);
   } else {
   } else {
-    GPR_ASSERT(strcmp(session_reused->value.data, "false") == 0);
+    GPR_ASSERT(strncmp(session_reused->value.data, "false",
+                       session_reused->value.length) == 0);
   }
   }
 }
 }