Commit 4d3d952b6e for openssl.org

commit 4d3d952b6e8d345dc6bf8c3825d700a68afdf568
Author: Herman Semenoff <GermanAizek@yandex.ru>
Date:   Sat Apr 25 04:48:15 2026 +0300

    crypto, ssl: fix printf formats according to param types

    inttypes.h is also used for more accurate compatibility with all
    platforms, as it is the more correct choice according to C standard.

    Signed-off-by: Herman Semenoff <GermanAizek@yandex.ru>

    Reviewed-by: Paul Dale <paul.dale@oracle.com>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    MergeDate: Mon Jun  1 06:58:24 2026
    (Merged from https://github.com/openssl/openssl/pull/30969)

diff --git a/crypto/asn1/x_int64.c b/crypto/asn1/x_int64.c
index f7cd7cbd95..9f2a3aedc2 100644
--- a/crypto/asn1/x_int64.c
+++ b/crypto/asn1/x_int64.c
@@ -8,6 +8,7 @@
  */

 #include <stdio.h>
+#include <inttypes.h>
 #include "internal/cryptlib.h"
 #include "internal/numbers.h"
 #include <openssl/asn1t.h>
@@ -113,8 +114,8 @@ static int uint64_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
     int indent, const ASN1_PCTX *pctx)
 {
     if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
-        return BIO_printf(out, "%jd\n", **(int64_t **)pval);
-    return BIO_printf(out, "%ju\n", **(uint64_t **)pval);
+        return BIO_printf(out, "%" PRId64 "\n", **(int64_t **)pval);
+    return BIO_printf(out, "%" PRIu64 "\n", **(uint64_t **)pval);
 }

 /* 32-bit variants */
diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c
index 8c6afa8607..60c769af93 100644
--- a/crypto/cmp/cmp_client.c
+++ b/crypto/cmp/cmp_client.c
@@ -10,6 +10,7 @@
  */

 #include "cmp_local.h"
+#include <inttypes.h>

 #define IS_CREP(t) ((t) == OSSL_CMP_PKIBODY_IP || (t) == OSSL_CMP_PKIBODY_CP \
     || (t) == OSSL_CMP_PKIBODY_KUP)
@@ -309,7 +310,7 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
             }
             if (check_after < 0 || (uint64_t)check_after > (sleep ? ULONG_MAX / 1000 : INT_MAX)) {
                 ERR_raise(ERR_LIB_CMP, CMP_R_CHECKAFTER_OUT_OF_RANGE);
-                if (BIO_snprintf(str, OSSL_CMP_PKISI_BUFLEN, "value = %jd",
+                if (BIO_snprintf(str, OSSL_CMP_PKISI_BUFLEN, "value = %" PRId64,
                         check_after)
                     >= 0)
                     ERR_add_error_data(1, str);
diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c
index 5a9e49480c..c304777bda 100644
--- a/crypto/ocsp/ocsp_prn.c
+++ b/crypto/ocsp/ocsp_prn.c
@@ -98,7 +98,7 @@ int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *o, unsigned long flags)
     if (BIO_write(bp, "OCSP Request Data:\n", 19) <= 0)
         goto err;
     l = ASN1_INTEGER_get(inf->version);
-    if (BIO_printf(bp, "    Version: %lu (0x%lx)", l + 1, l) <= 0)
+    if (BIO_printf(bp, "    Version: %ld (0x%lx)", l + 1, l) <= 0)
         goto err;
     if (inf->requestorName != NULL) {
         if (BIO_write(bp, "\n    Requestor Name: ", 21) <= 0)
@@ -166,7 +166,7 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags)
         goto err;
     rd = &br->tbsResponseData;
     l = ASN1_INTEGER_get(rd->version);
-    if (BIO_printf(bp, "\n    Version: %lu (0x%lx)\n", l + 1, l) <= 0)
+    if (BIO_printf(bp, "\n    Version: %ld (0x%lx)\n", l + 1, l) <= 0)
         goto err;
     if (BIO_puts(bp, "    Responder Id: ") <= 0)
         goto err;
diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c
index aeb03bfeb2..0fc3e5a334 100644
--- a/ssl/ssl_txt.c
+++ b/ssl/ssl_txt.c
@@ -104,7 +104,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
 #endif
     if (x->ext.tick_lifetime_hint) {
         if (BIO_printf(bp,
-                "\n    TLS session ticket lifetime hint: %ld (seconds)",
+                "\n    TLS session ticket lifetime hint: %lu (seconds)",
                 x->ext.tick_lifetime_hint)
             <= 0)
             goto err;
@@ -123,7 +123,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
         if (!ssl_cipher_get_evp(NULL, x, NULL, NULL, NULL, NULL, &comp, 0))
             goto err;
         if (comp == NULL) {
-            if (BIO_printf(bp, "\n    Compression: %d", x->compress_meth) <= 0)
+            if (BIO_printf(bp, "\n    Compression: %u", x->compress_meth) <= 0)
                 goto err;
         } else {
             if (BIO_printf(bp, "\n    Compression: %d (%s)", comp->id,