summaryrefslogtreecommitdiffstats
path: root/crypto/params_from_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/params_from_text.c')
-rw-r--r--crypto/params_from_text.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/params_from_text.c b/crypto/params_from_text.c
index 360f8933e1..3fe65af3c5 100644
--- a/crypto/params_from_text.c
+++ b/crypto/params_from_text.c
@@ -118,7 +118,13 @@ static int prepare_from_text(const OSSL_PARAM *paramdefs, const char *key,
break;
case OSSL_PARAM_OCTET_STRING:
if (*ishex) {
- *buf_n = strlen(value) >> 1;
+ size_t hexdigits = strlen(value);
+ if ((hexdigits % 2) != 0) {
+ /* We don't accept an odd number of hex digits */
+ ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_ODD_NUMBER_OF_DIGITS);
+ return 0;
+ }
+ *buf_n = hexdigits >> 1;
} else {
*buf_n = value_n;
}