Copilot commented on code in PR #13318:
URL: https://github.com/apache/trafficserver/pull/13318#discussion_r3464497407


##########
src/iocore/net/SSLUtils.cc:
##########
@@ -1167,6 +1167,8 @@ setClientCertCACerts(SSL *ssl, const char *file, const 
char *dir)
     X509_STORE *ctx = X509_STORE_new();
     if (X509_STORE_load_locations(ctx, file && file[0] != '\0' ? file : 
nullptr, dir && dir[0] != '\0' ? dir : nullptr)) {
       SSL_set0_verify_cert_store(ssl, ctx);
+    } else {
+      X509_STORE_free(ctx);
     }

Review Comment:
   `X509_STORE_new()` can return `nullptr`. The current code unconditionally 
passes `ctx` into `X509_STORE_load_locations()`, which may crash on allocation 
failure. Since this function is called per-handshake, it’s worth handling the 
allocation failure explicitly and freeing only when `ctx` is non-null / load 
fails.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to