Commit 5a4883d5a3 for openssl.org
commit 5a4883d5a32571b884f8c4e706e3726f761de7cb
Author: Bob Beck <beck@openssl.org>
Date: Wed Jun 17 19:24:36 2026 -0600
Convert BIO_snprintf() usage in describe_param_type()
This adds the correct truncation check for snprintf() to
each block that advances the index.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
MergeDate: Wed Aug 26 16:20:14 2026
(Merged from https://github.com/openssl/openssl/pull/31640)
diff --git a/apps/lib/app_params.c b/apps/lib/app_params.c
index cb569bb0c9..e9dee852af 100644
--- a/apps/lib/app_params.c
+++ b/apps/lib/app_params.c
@@ -7,6 +7,8 @@
* https://www.openssl.org/source/license.html
*/
+#include <stdio.h>
+
#include "apps.h"
#include "app_params.h"
@@ -45,29 +47,29 @@ static int describe_param_type(char *buf, size_t bufsz, const OSSL_PARAM *param)
break;
}
- printed_len = BIO_snprintf(buf, bufsz, "%s: ", param->key);
- if (printed_len > 0) {
+ printed_len = snprintf(buf, bufsz, "%s: ", param->key);
+ if (printed_len > 0 && (size_t)printed_len < bufsz) {
buf += printed_len;
bufsz -= printed_len;
}
- printed_len = BIO_snprintf(buf, bufsz, "%s%s", type_mod, type);
- if (printed_len > 0) {
+ printed_len = snprintf(buf, bufsz, "%s%s", type_mod, type);
+ if (printed_len > 0 && (size_t)printed_len < bufsz) {
buf += printed_len;
bufsz -= printed_len;
}
if (show_type_number) {
- printed_len = BIO_snprintf(buf, bufsz, " [%u]", param->data_type);
- if (printed_len > 0) {
+ printed_len = snprintf(buf, bufsz, " [%u]", param->data_type);
+ if (printed_len > 0 && (size_t)printed_len < bufsz) {
buf += printed_len;
bufsz -= printed_len;
}
}
if (param->data_size == 0)
- printed_len = BIO_snprintf(buf, bufsz, " (arbitrary size)");
+ printed_len = snprintf(buf, bufsz, " (arbitrary size)");
else
- printed_len = BIO_snprintf(buf, bufsz, " (max %zu bytes large)",
+ printed_len = snprintf(buf, bufsz, " (max %zu bytes large)",
param->data_size);
- if (printed_len > 0) {
+ if (printed_len > 0 && (size_t)printed_len < bufsz) {
buf += printed_len;
bufsz -= printed_len;
}