From 8eaafeea61cafe968ce422dde5c0713e7c70cd0a Mon Sep 17 00:00:00 2001 From: bcook <> Date: Sat, 18 Jul 2015 17:19:56 +0000 Subject: check sscanf conversion, fixes Coverity 21666 ok doug@, miod@, guenther@ --- src/regress/lib/libcrypto/evp/evptest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/evp/evptest.c b/src/regress/lib/libcrypto/evp/evptest.c index a71c1fb55a..bd5da475f1 100644 --- a/src/regress/lib/libcrypto/evp/evptest.c +++ b/src/regress/lib/libcrypto/evp/evptest.c @@ -81,10 +81,14 @@ convert(unsigned char *s) unsigned int n; if (!s[1]) { - fprintf(stderr, "Odd number of hex digits!"); + fprintf(stderr, "Odd number of hex digits!\n"); exit(4); } - sscanf((char *)s, "%2x",&n); + if (sscanf((char *)s, "%2x", &n) != 1) { + fprintf(stderr, "Invalid hex value at %s\n", s); + exit(4); + } + *d = (unsigned char)n; } return s - d; -- cgit v1.2.3-55-g6feb