[ZBX-8914] Server incorrectly parses header, if TCP packet is fragmented within first 5 bytes Created: 2014 Oct 16 Updated: 2017 Dec 23 Resolved: 2016 Jan 13 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Proxy (P), Server (S) |
Affects Version/s: | 2.5.0 |
Fix Version/s: | 3.0.0alpha6 |
Type: | Incident report | Priority: | Minor |
Reporter: | Filipp Sudanov (Inactive) | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | protocols, proxy, server, tcp | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Description |
When server / proxy receives data, it analyses first 5 bytes to see, if they are the protocol header. |
Comments |
Comment by Filipp Sudanov (Inactive) [ 2014 Oct 16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
How to replicate - put ZBXD to your clipboard, run stty raw && nc 127.0.0.1 10051 and paste into the terminal. Server does not wait for subsequent bytes, but instantly closes the connection and writes " trapper got 'ZBXD' " to it's log. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Glebs Ivanovskis (Inactive) [ 2015 Dec 22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(1) Old protocols are still supported but changes should be documented in Upgrade notes anyway. I would like to document the differences between old and new zbx_tcp_recv_ext() in details at least here. With a ',' I will denote interruptions in data flow, with a '.' I will denote socket closing moment.
8. is a payback for 2. and 3. Any ideas on how to improve the situation are appreciated. glebs.ivanovskis Subtle change of return value in 10. caused a regression Revision 58162 fixes return value in the following fashion:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Glebs Ivanovskis (Inactive) [ 2015 Dec 22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Fix for trunk is available in development branch svn://svn.zabbix.com/branches/dev/ZBX-8914 revision 57293. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Andris Zeila [ 2015 Dec 22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(2) The following code can cause alignment error on non intel CPUs: expected_len = zbx_letoh_uint64(*(zbx_uint64_t *)(s->buf_stat + ZBX_TCP_HEADER_LEN)); glebs.ivanovskis Can this issue be solved in this way? memcpy(&expected_len, s->buf_stat + ZBX_TCP_HEADER_LEN, sizeof(zbx_uint64_t)); expected_len = zbx_letoh_uint64(expected_len); wiper yes glebs.ivanovskis RESOLVED in r57339. wiper CLOSED | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Andris Zeila [ 2015 Dec 23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(3) If the initial packet contains header + length, but is larger than expected length, then 'message is shorter than expected' warning is logged. The simple fix would be just to change the message to something like 'received data length differs from expected data length'. glebs.ivanovskis Improved error messages as we discussed with zalex_ua to provide more information. I've spotted a bug when we receive a slow-coming plain text message and ZBX_TCP_READ_UNTIL_CLOSE flag is set we can stick with static buffer and wont be able to read the full message if it's longer. Also fixed. RESOLVED wiper CLOSED | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Andris Zeila [ 2016 Jan 12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Successfully tested, please check my changes regarding to unrelated compilation warnings in r57558 glebs.ivanovskis Thanks, looks good! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment by Glebs Ivanovskis (Inactive) [ 2016 Jan 13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Fixed in pre-3.0.0alpha6 (trunk) r57583. |