-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logproto: fix invalid buffer handling when encoding() is used #3892
Conversation
Build SUCCESS |
ee4f700
to
26332c7
Compare
26332c7
to
f7e2226
Compare
@kira-syslogng do stresstest |
Build SUCCESS |
Kira-stress-test: Build SUCCESS |
@Kokan I need to validate my theory, but this might be one of the root causes of the Big5 encoding issue that we've discussed IRL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug itself is a good catch, must have been very difficult to reproduce and fix it. However I don't think we need to change the argument list of fetch_from_buffer().
f7e2226
to
f06ad77
Compare
f06ad77
to
e02546a
Compare
@kira-syslogng do stresstest |
Build SUCCESS |
Kira-stress-test: Build SUCCESS |
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
1c36b11
to
cd59631
Compare
Build FAILURE |
cd59631
to
142de5a
Compare
Build SUCCESS |
7115c34
to
f9d1081
Compare
@kira-syslogng do stresstest |
Build SUCCESS |
Kira-stress-test: Build SUCCESS |
We're running some additional tests before merge. |
This test reproduces a bug in log_proto_text_server_split_buffer(), where an invalid (partially overwritten) buffer slice is passed to our decoder function (log_proto_text_server_get_raw_size_of_buffer()). The subsequent commit fixes this bug. Signed-off-by: László Várady <laszlo.varady@protonmail.com>
log_proto_text_server_split_buffer() moves data within self->data for which we maintain additional pointers: buffer_start. This pointer needs to be updated after the memmove() call, otherwise it could point to partially overwritten data in case the memmove() operation overlaps. A few lines below, buffer_start is passed to a decoder function called log_proto_text_server_get_raw_size_of_buffer(), which could fail and report incorrect positions for file sources. This could result in message duplication, partial message loss, but it only occurs when non-fixed length or less known fixed-length encodings are used (encodings that are not listed in fixed_encodings). Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
split_buffer() moves data from the middle/end of the buffer to the beginning, which is the responsibility of LogProtoBufferedServer. Currently, the split logic is not called when the end of the buffer is reached, it is called on specific LogProtoTextServer events, so the method is currently "protected" instead of "private". Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
Signed-off-by: László Várady <laszlo.varady@protonmail.com>
f9d1081
to
46bfe6c
Compare
Build SUCCESS |
log_proto_text_server_split_buffer()
moves data withinself->data
for which we maintain additional pointers:buffer_start
.This pointer needs to be updated after the
memmove()
call, otherwise it could point to partially overwritten data in case thememmove()
operation overlaps.A few lines below my fix,
buffer_start
is passed to a decoder function calledlog_proto_text_server_get_raw_size_of_buffer()
, which could fail and report incorrect positions.This could result in message duplication, partial message loss, but it only occurs when non-fixed length or less known fixed-length encodings are used (encodings that are not listed in
fixed_encodings
).