aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBob Beck <[email protected]>2026-06-18 03:24:36 +0200
committerNeil Horman <[email protected]>2026-08-26 18:20:02 +0200
commit5a4883d5a32571b884f8c4e706e3726f761de7cb (patch)
tree6deb4683537d34ce144cd6038b52e7bef4367cc0 /apps
parentConvert BIO_snprintf() callers that detect truncation to snprintf(). (diff)
downloadopenssl-5a4883d5a32571b884f8c4e706e3726f761de7cb.tar.gz
openssl-5a4883d5a32571b884f8c4e706e3726f761de7cb.zip
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 <[email protected]> Reviewed-by: Andrew Dinh <[email protected]> MergeDate: Wed Aug 26 16:20:14 2026 (Merged from https://github.com/openssl/openssl/pull/31640)
Diffstat (limited to 'apps')
-rw-r--r--apps/lib/app_params.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/apps/lib/app_params.c b/apps/lib/app_params.c
index cb569bb0c98..e9dee852af4 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;
}