Commit 0642e44723 for openssl.org
commit 0642e44723492a4168374fffe73c1adc7fa609f9
Author: Herman Semenoff <GermanAizek@yandex.ru>
Date: Sat Apr 25 04:34:46 2026 +0300
apps: 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:23 2026
(Merged from https://github.com/openssl/openssl/pull/30969)
diff --git a/apps/enc.c b/apps/enc.c
index 69e4a92908..3d06a6ef03 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -24,6 +24,7 @@
#include <openssl/comp.h>
#endif
#include <ctype.h>
+#include <inttypes.h>
#undef SIZE
#undef BSIZE
@@ -826,8 +827,8 @@ int enc_main(int argc, char **argv)
ret = 0;
if (verbose) {
- BIO_printf(bio_err, "bytes read : %8ju\n"
- "bytes written: %8ju\n",
+ BIO_printf(bio_err, "bytes read : %8" PRIu64 "\n"
+ "bytes written: %8" PRIu64 "\n",
BIO_number_read(in), BIO_number_written(out));
}
end:
diff --git a/apps/lib/app_params.c b/apps/lib/app_params.c
index 86d37f31d8..cb569bb0c9 100644
--- a/apps/lib/app_params.c
+++ b/apps/lib/app_params.c
@@ -56,7 +56,7 @@ static int describe_param_type(char *buf, size_t bufsz, const OSSL_PARAM *param)
bufsz -= printed_len;
}
if (show_type_number) {
- printed_len = BIO_snprintf(buf, bufsz, " [%d]", param->data_type);
+ printed_len = BIO_snprintf(buf, bufsz, " [%u]", param->data_type);
if (printed_len > 0) {
buf += printed_len;
bufsz -= printed_len;
diff --git a/apps/rand.c b/apps/rand.c
index 536d7a64a6..7aec7b6e17 100644
--- a/apps/rand.c
+++ b/apps/rand.c
@@ -159,7 +159,7 @@ int rand_main(int argc, char **argv)
if (shift != 0) {
/* check for overflow */
if ((UINT64_MAX >> shift) < (size_t)num) {
- BIO_printf(bio_err, "%lu bytes with suffix overflows\n",
+ BIO_printf(bio_err, "%ld bytes with suffix overflows\n",
num);
goto opthelp;
}
diff --git a/apps/s_client.c b/apps/s_client.c
index 08ad758ebf..3afbf24166 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -9,6 +9,7 @@
*/
#include "internal/e_os.h"
+#include <inttypes.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -186,7 +187,7 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *identity,
}
if (max_psk_len > INT_MAX || key_len > (long)max_psk_len) {
BIO_printf(bio_err,
- "psk buffer of callback is too small (%d) for key (%ld)\n",
+ "psk buffer of callback is too small (%u) for key (%ld)\n",
max_psk_len, key_len);
OPENSSL_free(key);
return 0;
@@ -340,7 +341,7 @@ static int serverinfo_cli_parse_cb(SSL *s, unsigned int ext_type,
ext_buf[3] = (unsigned char)(inlen);
memcpy(ext_buf + 4, in, inlen);
- BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %d",
+ BIO_snprintf(pem_name, sizeof(pem_name), "SERVERINFO FOR EXTENSION %u",
ext_type);
PEM_write_bio(bio_c_out, pem_name, "", ext_buf, (long)(4 + inlen));
return 1;
@@ -1710,7 +1711,7 @@ int s_client_main(int argc, char **argv)
break;
default:
BIO_printf(bio_err,
- "%s: Max Fragment Len %u is out of permitted values",
+ "%s: Max Fragment Len %d is out of permitted values",
prog, len);
goto opthelp;
}
@@ -3850,8 +3851,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
#endif
BIO_printf(bio,
- "---\nSSL handshake has read %ju bytes "
- "and written %ju bytes\n",
+ "---\nSSL handshake has read %" PRIu64 " bytes "
+ "and written %" PRIu64 " bytes\n",
BIO_number_read(SSL_get_rbio(s)),
BIO_number_written(SSL_get_wbio(s)));
}
diff --git a/apps/s_server.c b/apps/s_server.c
index 7ed53093d6..baa8f64363 100644
--- a/apps/s_server.c
+++ b/apps/s_server.c
@@ -209,7 +209,7 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
}
if (key_len > (int)max_psk_len) {
BIO_printf(bio_err,
- "psk buffer of callback is too small (%d) for key (%ld)\n",
+ "psk buffer of callback is too small (%u) for key (%ld)\n",
max_psk_len, key_len);
OPENSSL_free(key);
return 0;