File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,7 +120,10 @@ impl PacketBus {
120120 Socket :: Web ( socket) => match socket. next ( ) . await {
121121 Some ( Ok ( Message :: Binary ( buf) ) ) => {
122122 if buf. len ( ) < 4 {
123- return None ;
123+ return Some ( Err ( std:: io:: Error :: new (
124+ std:: io:: ErrorKind :: InvalidData ,
125+ format ! ( "Received packet is too short: {}" , buf. len( ) ) ,
126+ ) ) ) ;
124127 }
125128
126129 let mut data_buf = buf[ 2 ..] . to_vec ( ) ;
@@ -172,6 +175,16 @@ impl PacketBus {
172175 match read. await {
173176 Some ( Ok ( buf) ) => {
174177 let mut data_buf = buf;
178+ if data_buf. len ( ) < 3 {
179+ return Some ( Err ( std:: io:: Error :: new (
180+ std:: io:: ErrorKind :: InvalidData ,
181+ format ! (
182+ "Received packet is too short: {}" ,
183+ data_buf. len( )
184+ ) ,
185+ ) ) ) ;
186+ }
187+
175188 if self . client_enryption_multiple != 0 {
176189 decrypt_packet (
177190 & mut data_buf,
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ async fn run_player(mut player: Player) {
288288 break ;
289289 } ,
290290 _ => {
291- player. close( format!( "Due to unknown error: {:? }" , e) ) . await ;
291+ player. close( format!( "{ }" , e) ) . await ;
292292 break ;
293293 }
294294 }
You can’t perform that action at this time.
0 commit comments