summaryrefslogtreecommitdiffstats
path: root/crypto/o_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/o_str.c')
-rw-r--r--crypto/o_str.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/crypto/o_str.c b/crypto/o_str.c
index 142ac4ba44..dbecf4841c 100644
--- a/crypto/o_str.c
+++ b/crypto/o_str.c
@@ -187,7 +187,12 @@ unsigned char *openssl_hexstr2buf_sep(const char *str, long *buflen,
unsigned char *buf;
size_t buf_n, tmp_buflen;
- buf_n = strlen(str) >> 1;
+ buf_n = strlen(str);
+ if (buf_n <= 1) {
+ ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_HEX_STRING_TOO_SHORT);
+ return NULL;
+ }
+ buf_n /= 2;
if ((buf = OPENSSL_malloc(buf_n)) == NULL) {
ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE);
return NULL;