-
Notifications
You must be signed in to change notification settings - Fork 43
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
Clear the right number of bytes in StreamBuffer #96
base: master
Are you sure you want to change the base?
Clear the right number of bytes in StreamBuffer #96
Conversation
The wrong number of bytes was being cleared in StreamBuffer::grow. That could lead to memory access out of bounds.
d2c82b2
to
34cf047
Compare
Hi! I was helping with the debugging of IOC that motivated this PR. We reached this function while debugging a segfault, which would occur sometimes during that We identified the segfault when using the following combination for input control (using asyn 4.42 and StreamDevice 2.8.22: MaxInput = 6;
Separator = "";
Terminator = "";
inTerminator= "";
outTerminator= ""; We also identified it occurring in other locations, such as |
Are you able to reproduce the fault with a simulated device which you can send me?
I do that to ensure I always have 0 terminated strings without having to add a 0 each time I add a char to the buffer. |
I think that the actual bug was in |
Sorry for the very long delay. It turns out I had to work on other demands and couldn't put effort on it yet.
I've taken a quick look at the bugs you've found, and it seems that corrupts the data while keeping the metadata ( In the first bug, the buffer will be full of data and no In the second one, I'd like we could test the patched code in the IOC we saw the faults to check if that's really the case. However, device firmware and IOC have changed significantly since then. We're no longer using BTW, we may turn this into a GitHub issue if you will. |
You are right. Those should not corrupt the meta data. Your problem seems to be something else. |
Indeed. I hadn't noticed that. However, in our case, it probably switches to dynamically allocated buffer away before reaching the fault due to the large amount of data read.
Would that happen with the bugs you've found? I'm not familiar with the asyn interface StreamDevice uses, but it seams to me it reads a limited amount of bytes, such as in AsynDriverInterface::readHandler. Having |
No, none of those two bugs should lead to a buffer overflow when writing. At least none of the |
Maybe in AsynDriverInterface.cc I need to set |
No. |
The wrong number of bytes was being cleared in StreamBuffer::grow. That could lead to memory access out of bounds.
We identified that after a number of Segmentation Faults in our project.
By the way, is that clear in the final bytes really necessary?