File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed
tiny_websockets/network/generic_esp Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,15 @@ namespace websockets { namespace network {
4848 }
4949
5050 WSString readLine () override {
51- int val ;
52- WSString line;
53- do {
54- yield ();
55- val = client.read ();
56- if (val < 0 ) continue ;
57- line += (char )val ;
58- } while (val != ' \n ' );
59- if (! available ()) close ();
51+ WSString line = " " ;
52+
53+ int ch = - 1 ;
54+ while ( ch != ' \n ' && available ()) {
55+ ch = client.read ();
56+ if (ch < 0 ) continue ;
57+ line += (char ) ch ;
58+ }
59+
6060 return line;
6161 }
6262
Original file line number Diff line number Diff line change @@ -277,6 +277,12 @@ namespace websockets {
277277 WSString line = " " ;
278278 while (true ) {
279279 line = this ->_client ->readLine ();
280+
281+ if (line.size () < 2 ) {
282+ close (CloseReason_ProtocolError);
283+ return false ;
284+ }
285+
280286 if (line == " \r\n " ) break ;
281287 // remove /r/n from line end
282288 line = line.substr (0 , line.size () - 2 );
You can’t perform that action at this time.
0 commit comments