]> git.kaiwu.me - nginx.git/commitdiff
SSL: overcame possible buffer over-read in ngx_ssl_error().
authorValentin Bartenev <vbart@nginx.com>
Tue, 18 Oct 2016 17:46:06 +0000 (20:46 +0300)
committerValentin Bartenev <vbart@nginx.com>
Tue, 18 Oct 2016 17:46:06 +0000 (20:46 +0300)
It appeared that ERR_error_string_n() cannot handle zero buffer size well enough
and causes over-read.

The problem has also been fixed in OpenSSL:
https://git.openssl.org/?p=openssl.git;h=e5c1361580d8de79682958b04a5f0d262e680f8b

src/event/ngx_event_openssl.c

index 68d02bfef1c63ffa61c39ab8c4c8b24af5d120f3..cddcefdcf3afac40c0cf51581abd7ad35b41ff4b 100644 (file)
@@ -2137,7 +2137,9 @@ ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, char *fmt, ...)
             break;
         }
 
-        if (p >= last) {
+        /* ERR_error_string_n() requires at least one byte */
+
+        if (p >= last - 1) {
             goto next;
         }