Added check for MQTT 3.1.1 reserved flag == 0 on connect flags

This commit is contained in:
selva.andre
2014-07-23 00:08:59 +02:00
parent 465d7123f6
commit 8185811188
2 changed files with 27 additions and 1 deletions
@@ -120,6 +120,12 @@ public class ConnectDecoder extends DemuxDecoder {
//Connection flag
byte connFlags = in.readByte();
if (message.getProcotolVersion() == VERSION_3_1_1) {
if ((connFlags & 0x01) != 0) { //bit(0) of connection flags is != 0
throw new CorruptedFrameException("Received a CONNECT with connectionFlags[0(bit)] != 0");
}
}
boolean cleanSession = ((connFlags & 0x02) >> 1) == 1 ? true : false;
boolean willFlag = ((connFlags & 0x04) >> 2) == 1 ? true : false;
byte willQos = (byte) ((connFlags & 0x18) >> 3);