diff options
author | Brent Cook <bcook@cvs.openbsd.org> | 2015-07-18 17:19:57 +0000 |
---|---|---|
committer | Brent Cook <bcook@cvs.openbsd.org> | 2015-07-18 17:19:57 +0000 |
commit | efa4ecc369d7e643ceb5f25ae99850d889c2ca76 (patch) | |
tree | bb9da34e0e11c98f02720054787683e90ea77cac /regress | |
parent | 35dd73470219b2bce74a2b27a207102b265adedf (diff) |
check sscanf conversion, fixes Coverity 21666
ok doug@, miod@, guenther@
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/evp/evptest.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/regress/lib/libcrypto/evp/evptest.c b/regress/lib/libcrypto/evp/evptest.c index a71c1fb55ac..bd5da475f1d 100644 --- a/regress/lib/libcrypto/evp/evptest.c +++ b/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; |