-
Notifications
You must be signed in to change notification settings - Fork 11
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
Potential bug(s) with leftover processing #17
Comments
'len' is the total number of bytes available to read right now.
So, if If
If the remainder is 150 then we must have 38 leftover bytes. If you then get a buffer of 140 bytes, the you should end up with a total of 178 leftover bytes, and no demuxed packets (except you won't, because it looks like there is in fact a bug there!) If |
Just pushed a fix for that, along with some additional comments that should help make the logic clearer: 71e4497 |
Ah HA! That makes tons of sense (I had remainder backwards!) -- thank you so much for taking the time to explain and for the patch. |
I'm currently in the process of mapping out the processing logic and I'm trying to understand the current logic around partial packet processing / think there might be a bug lurking.
I wanted to run it by you in case I should open a patch.
It's related to this code:
In particular, I'm not sure of a few things here:
if (len < remainder)
as opposed toif (len + remainder < PACKET_LEN)
It seems to me that the logic as written could result in a situation where the remainder was, say,
150
, and the new data had a length of140
. The result would be150 + 140 = 290
which is well abovePACKET_LEN (188)
and could very well be a new packet (but is being skipped).Why isn't
this.ptr
updated? My understanding is thatthis.ptr
is supposed to indicate how much data is inthis.leftover
. When we add data to the leftover and return without processing, but without updatingthis.ptr
that data would be overwritten the next timeprocess()
is invoked, right?this.ptr
is also potentially not updated later in this conditional.Hopefully this makes sense; please forgive me if I'm just misunderstanding the point of
this.ptr
/len
/remainder
The text was updated successfully, but these errors were encountered: