Java: fixed the calculation related to the response buffer.
We need to take into account the size of the nxt_unit_response_t structure itself when calculating where to start appending data to in memory. Closes: <https://github.com/nginx/unit/issues/923> Reported-by: Alejandro Colomar <alx@kernel.org> Reviewed-by: Andrew Clayton <a.clayton@nginx.org> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
committed by
Andrew Clayton
parent
2d0e502d2a
commit
b6216f0bb7
@@ -334,7 +334,8 @@ nxt_java_get_response_info(jlong req_info_ptr, uint32_t extra_fields,
|
|||||||
- req->response->fields_count
|
- req->response->fields_count
|
||||||
|| extra_data > (uint32_t) (buf->end - buf->free))
|
|| extra_data > (uint32_t) (buf->end - buf->free))
|
||||||
{
|
{
|
||||||
p = buf->start + req->response_max_fields * sizeof(nxt_unit_field_t);
|
p = buf->start + sizeof(nxt_unit_response_t)
|
||||||
|
+ req->response_max_fields * sizeof(nxt_unit_field_t);
|
||||||
|
|
||||||
max_size = 2 * (buf->end - p);
|
max_size = 2 * (buf->end - p);
|
||||||
if (max_size > nxt_unit_buf_max()) {
|
if (max_size > nxt_unit_buf_max()) {
|
||||||
@@ -936,8 +937,8 @@ nxt_java_Response_reset(JNIEnv *env, jclass cls, jlong req_info_ptr)
|
|||||||
|
|
||||||
buf = req->response_buf;
|
buf = req->response_buf;
|
||||||
|
|
||||||
buf->free = buf->start + req->response_max_fields
|
buf->free = buf->start + sizeof(nxt_unit_response_t)
|
||||||
* sizeof(nxt_unit_field_t);
|
+ req->response_max_fields * sizeof(nxt_unit_field_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2148,7 +2148,8 @@ nxt_unit_response_realloc(nxt_unit_request_info_t *req,
|
|||||||
resp->status = req->response->status;
|
resp->status = req->response->status;
|
||||||
resp->content_length = req->response->content_length;
|
resp->content_length = req->response->content_length;
|
||||||
|
|
||||||
p = buf->start + max_fields_count * sizeof(nxt_unit_field_t);
|
p = buf->start + sizeof(nxt_unit_response_t)
|
||||||
|
+ max_fields_count * sizeof(nxt_unit_field_t);
|
||||||
f = resp->fields;
|
f = resp->fields;
|
||||||
|
|
||||||
for (i = 0; i < req->response->fields_count; i++) {
|
for (i = 0; i < req->response->fields_count; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user