Liveview: add some sanity checks to the incoming data lenghts
This commit is contained in:
parent
4eb56eb9ca
commit
6a09023c24
|
@ -180,11 +180,16 @@ public class LiveviewIoThread extends GBDeviceIoThread {
|
||||||
incoming = new byte[1];
|
incoming = new byte[1];
|
||||||
break;
|
break;
|
||||||
case HEADER_LEN:
|
case HEADER_LEN:
|
||||||
|
int headerSize = 0xff & incoming[0];
|
||||||
|
if (headerSize < 0)
|
||||||
|
throw new IOException();
|
||||||
state = ReaderState.HEADER;
|
state = ReaderState.HEADER;
|
||||||
incoming = new byte[incoming[0]];
|
incoming = new byte[headerSize];
|
||||||
break;
|
break;
|
||||||
case HEADER:
|
case HEADER:
|
||||||
int payloadSize = getLastInt(msgStream);
|
int payloadSize = getLastInt(msgStream);
|
||||||
|
if (payloadSize < 0 || payloadSize > 8000) //this will possibly be changed in the future
|
||||||
|
throw new IOException();
|
||||||
state = ReaderState.PAYLOAD;
|
state = ReaderState.PAYLOAD;
|
||||||
incoming = new byte[payloadSize];
|
incoming = new byte[payloadSize];
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue