]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* modules/ssl/ssl_util.c (ssl_asn1_table_set): Add assertion
authorJoe Orton <jorton@apache.org>
Mon, 6 Jul 2026 12:08:49 +0000 (12:08 +0000)
committerJoe Orton <jorton@apache.org>
Mon, 6 Jul 2026 12:08:49 +0000 (12:08 +0000)
  for the (likely unreachable) i2d_PrivateKey() failure case.

Submitted by: Sayed Kaif <metsw24 gmail.com>
Github: closes #619

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1935941 13f79535-47bb-0310-9956-ffa450edef68

modules/ssl/ssl_util.c

index 12ffff511e24afd6bfa9ed839e7fc30f54258ce1..cf28968233003b0e8a13b2dbffe2c98f461e8849 100644 (file)
@@ -201,9 +201,13 @@ ssl_asn1_t *ssl_asn1_table_set(apr_hash_t *table, const char *key,
 {
     apr_ssize_t klen = strlen(key);
     ssl_asn1_t *asn1 = apr_hash_get(table, key, klen);
-    apr_size_t length = i2d_PrivateKey(pkey, NULL);
+    int derlen = i2d_PrivateKey(pkey, NULL);
+    apr_size_t length;
     unsigned char *p;
 
+    ap_assert(derlen > 0); /* should never happen for any loaded key */
+    length = (apr_size_t)derlen;
+
     /* Re-use structure if cached previously. */
     if (asn1) {
         if (asn1->nData != length) {