diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-09-10 12:16:32 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-09-10 12:16:32 +0300 |
commit | bd4ca6a057ca6e480a47112b3d379d72a8819e8c (patch) | |
tree | 09c37e466b74aa0afd20824ac0b70c9b17b918e1 | |
parent | 22c88f0253d57756ad541326df09d1398a871708 (diff) | |
download | unit-bd4ca6a057ca6e480a47112b3d379d72a8819e8c.tar.gz unit-bd4ca6a057ca6e480a47112b3d379d72a8819e8c.tar.bz2 |
Fixing WebSocket frame retain function.
Some of the pointers were not adjusted after frame's memory re-allocation.
Fortunately, this function was not used and the bug has no effect.
-rw-r--r-- | src/nxt_unit.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 6b7d631d..539c381c 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -3288,7 +3288,7 @@ int nxt_unit_websocket_retain(nxt_unit_websocket_frame_t *ws) { char *b; - size_t size; + size_t size, hsize; nxt_unit_websocket_frame_impl_t *ws_impl; ws_impl = nxt_container_of(ws, nxt_unit_websocket_frame_impl_t, ws); @@ -3306,12 +3306,23 @@ nxt_unit_websocket_retain(nxt_unit_websocket_frame_t *ws) memcpy(b, ws_impl->buf->buf.start, size); + hsize = nxt_websocket_frame_header_size(b); + ws_impl->buf->buf.start = b; - ws_impl->buf->buf.free = b; + ws_impl->buf->buf.free = b + hsize; ws_impl->buf->buf.end = b + size; ws_impl->buf->free_ptr = b; + ws_impl->ws.header = (nxt_websocket_header_t *) b; + + if (ws_impl->ws.header->mask) { + ws_impl->ws.mask = (uint8_t *) b + hsize - 4; + + } else { + ws_impl->ws.mask = NULL; + } + return NXT_UNIT_OK; } |