Ensure we handle len == 0 in ERR_err_string_n
authorMatt Caswell <matt@openssl.org>
Wed, 12 Oct 2016 15:43:03 +0000 (16:43 +0100)
committerMatt Caswell <matt@openssl.org>
Sat, 15 Oct 2016 10:32:24 +0000 (11:32 +0100)
commit953ef2cbd0645a47b8d5c1af3fe8f77f2e56c133
tree92180f9eff64bba47a636ff1b2672048edb229ca
parent5389388a2b327ab5d4353e98b4e258fb683cde15
Ensure we handle len == 0 in ERR_err_string_n

If len == 0 in a call to ERR_error_string_n() then we can read beyond the
end of the buffer. Really applications should not be calling this function
with len == 0, but we shouldn't be letting it through either!

Thanks to Agostino Sarubbo for reporting this issue. Agostino's blog on
this issue is available here:
https://blogs.gentoo.org/ago/2016/10/14/openssl-libcrypto-stack-based-buffer-overflow-in-err_error_string_n-err-c/

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit e5c1361580d8de79682958b04a5f0d262e680f8b)
crypto/err/err.c