diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-10-28 00:01:46 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-10-28 00:01:46 +0300 |
commit | 735bb2f1276a7d768cffd1e780114a10018980cb (patch) | |
tree | c4f076d3ce8c94604e221bddaed7918145a5f646 /src/nxt_router.c | |
parent | 38a9027fe54edcfc8157174a8ce575ed7acefa79 (diff) | |
download | unit-735bb2f1276a7d768cffd1e780114a10018980cb.tar.gz unit-735bb2f1276a7d768cffd1e780114a10018980cb.tar.bz2 |
Added error response logging.
Every internal server error response should have a clear description in log.
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r-- | src/nxt_router.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 6277bd47..15706428 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -3722,6 +3722,7 @@ static void nxt_router_response_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg, void *data) { + size_t b_size, count; nxt_int_t ret; nxt_app_t *app; nxt_buf_t *b, *next; @@ -3787,15 +3788,20 @@ nxt_router_response_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg, nxt_http_request_send_body(task, r, NULL); } else { - size_t b_size = nxt_buf_is_mem(b) ? nxt_buf_mem_used_size(&b->mem) : 0; + b_size = nxt_buf_is_mem(b) ? nxt_buf_mem_used_size(&b->mem) : 0; - if (nxt_slow_path(b_size < sizeof(*resp))) { + if (nxt_slow_path(b_size < sizeof(nxt_unit_response_t))) { + nxt_alert(task, "response buffer too small: %z", b_size); goto fail; } resp = (void *) b->mem.pos; - if (nxt_slow_path(b_size < sizeof(*resp) - + resp->fields_count * sizeof(nxt_unit_field_t))) { + count = (b_size - sizeof(nxt_unit_response_t)) + / sizeof(nxt_unit_field_t); + + if (nxt_slow_path(count < resp->fields_count)) { + nxt_alert(task, "response buffer too small for fields count: %D", + resp->fields_count); goto fail; } |