comparison src/event/ngx_event_openssl.c @ 7454:e72c8a8a8b10

SSL: separate checks for errors in ngx_ssl_read_password_file(). Checking multiple errors at once is a bad practice, as in general it is not guaranteed that an object can be used after the error. In this particular case, checking errors after multiple allocations can result in excessive errors being logged when there is no memory available.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 31 Jan 2019 19:36:51 +0300
parents 873150addfeb
children 992bf7540a98
comparison
equal deleted inserted replaced
7453:873150addfeb 7454:e72c8a8a8b10
945 945
946 if (ngx_conf_full_name(cf->cycle, file, 1) != NGX_OK) { 946 if (ngx_conf_full_name(cf->cycle, file, 1) != NGX_OK) {
947 return NULL; 947 return NULL;
948 } 948 }
949 949
950 passwords = ngx_array_create(cf->temp_pool, 4, sizeof(ngx_str_t));
951 if (passwords == NULL) {
952 return NULL;
953 }
954
950 cln = ngx_pool_cleanup_add(cf->temp_pool, 0); 955 cln = ngx_pool_cleanup_add(cf->temp_pool, 0);
951 passwords = ngx_array_create(cf->temp_pool, 4, sizeof(ngx_str_t)); 956 if (cln == NULL) {
952
953 if (cln == NULL || passwords == NULL) {
954 return NULL; 957 return NULL;
955 } 958 }
956 959
957 cln->handler = ngx_ssl_passwords_cleanup; 960 cln->handler = ngx_ssl_passwords_cleanup;
958 cln->data = passwords; 961 cln->data = passwords;