You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If DataFrame::read_dataframe is passed too few bytes, it will still succeed and return a dataframe with an incomplete payload.
Example:
use websocket::DataFrame;letmut data = vec![0x8au8,0x08,0x19,0xac,0xab,0x8a,0x52,0x4e,0x05,0x00];println!("Incomplete header:\n {:?}",DataFrame::read_dataframe(&mut&data[..1],false));// This doesn't make senseprintln!("Incomplete payload:\n {:?}",DataFrame::read_dataframe(&mut&data[..6],false));println!("Complete dataframe:\n {:?}",DataFrame::read_dataframe(&mut&data[..],false));
data.push(0xff);println!("Additional data:\n {:?}",DataFrame::read_dataframe(&mut&data[..],false));
Thank's for the issue, the problem seems to be here. This only happens when you give it a non-blocking reader such as a &mut [u8], when reading from a TcpStream or similar it should block until it gets the amount of data in the header length.
With the "Additional Data" test you should see that you have 0xff leftover in your buffer. I think the only issue here is the "Incomplete Payload" scenario and it can be fixed by changing read_to_end to read_exact.
If
DataFrame::read_dataframe
is passed too few bytes, it will still succeed and return a dataframe with an incomplete payload.Example:
outputs
The text was updated successfully, but these errors were encountered: