]> git.kaiwu.me - nginx.git/commitdiff
SSL: improved validation of ssl_session_cache and ssl_ocsp_cache.
authorSergey Kandaurov <pluknet@nginx.com>
Mon, 17 Oct 2022 12:24:53 +0000 (16:24 +0400)
committerSergey Kandaurov <pluknet@nginx.com>
Mon, 17 Oct 2022 12:24:53 +0000 (16:24 +0400)
Now it properly detects invalid shared zone configuration with omitted size.
Previously it used to read outside of the buffer boundary.

Found with AddressSanitizer.

src/http/modules/ngx_http_ssl_module.c
src/mail/ngx_mail_ssl_module.c
src/stream/ngx_stream_ssl_module.c

index d74d4609435f21cc8b10cbedad42e88627f86abc..6fe5463dfbf9a0083a7ef382c3d2e268b80a51ae 100644 (file)
@@ -1093,7 +1093,7 @@ ngx_http_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                 len++;
             }
 
-            if (len == 0) {
+            if (len == 0 || j == value[i].len) {
                 goto invalid;
             }
 
@@ -1183,7 +1183,7 @@ ngx_http_ssl_ocsp_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         len++;
     }
 
-    if (len == 0) {
+    if (len == 0 || j == value[1].len) {
         goto invalid;
     }
 
index 2a1043e661e54eac04e1f1fd9c93b2d2a56bc1da..b80a0ca808a5ddb1afce2fc44a88d6e73c51f631 100644 (file)
@@ -682,7 +682,7 @@ ngx_mail_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                 len++;
             }
 
-            if (len == 0) {
+            if (len == 0 || j == value[i].len) {
                 goto invalid;
             }
 
index c5308322ac5c62e8f9633f6ce12ac5bb1390f17b..105aa1178a06d908fb4983a900092d3ca28e0c9a 100644 (file)
@@ -1073,7 +1073,7 @@ ngx_stream_ssl_session_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                 len++;
             }
 
-            if (len == 0) {
+            if (len == 0 || j == value[i].len) {
                 goto invalid;
             }