Klaus Demo nginx / 9ad18e4
Fixed ngx_open_cached_file() error handling. If of.err is 0, it means that there was a memory allocation error and no further logging and/or processing is needed. The of.failed string can be only accessed if of.err is not 0. Sergey Kandaurov 3 years ago
5 changed file(s) with 25 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
216216 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
217217 != NGX_OK)
218218 {
219 if (of.err == 0) {
220 return NGX_HTTP_INTERNAL_SERVER_ERROR;
221 }
222
219223 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
220224 "%s \"%s\" failed", of.failed, path.data);
221
222 if (of.err == 0) {
223 return NGX_HTTP_INTERNAL_SERVER_ERROR;
224 }
225225
226226 #if (NGX_HAVE_OPENAT)
227227 if (of.err == NGX_EMLINK
551551 if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
552552 != NGX_OK)
553553 {
554 if (of.err == 0) {
555 /* simulate successful logging */
556 return len;
557 }
558
554559 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
555560 "%s \"%s\" failed", of.failed, log.data);
556561 /* simulate successful logging */
13131313 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
13141314 != NGX_OK)
13151315 {
1316 if (of.err == 0) {
1317 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1318 return NGX_OK;
1319 }
1320
13161321 if (of.err != NGX_ENOENT
13171322 && of.err != NGX_ENOTDIR
13181323 && of.err != NGX_ENAMETOOLONG)
15121512 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
15131513 != NGX_OK)
15141514 {
1515 if (of.err == 0) {
1516 e->ip = ngx_http_script_exit;
1517 e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
1518 return;
1519 }
1520
15151521 if (of.err != NGX_ENOENT
15161522 && of.err != NGX_ENOTDIR
15171523 && of.err != NGX_ENAMETOOLONG)
442442 s->connection->pool)
443443 != NGX_OK)
444444 {
445 if (of.err == 0) {
446 /* simulate successful logging */
447 return len;
448 }
449
445450 ngx_log_error(NGX_LOG_CRIT, s->connection->log, ngx_errno,
446451 "%s \"%s\" failed", of.failed, log.data);
447452 /* simulate successful logging */