Program: 32513
Project: 32513
Buggy source:
private int transitionOnInput(byte rawByte,int state){
switch (state) {
case START_STATE:
    version=(rawByte & (byte)VERSION_MASK) >> 4;
  if (version == 0) {
    return ERROR_STATE;
  }
compression=(1 == ((rawByte & (byte)COMPRESSION_MASK) >> 3));
frameType=rawByte & (byte)FRAME_TYPE_MASK;
switch (version) {
case 0:
if (frameType != SdlPacket.FRAME_TYPE_CONTROL) {
return ERROR_STATE;
}
case 1:
case 2:
break;
default :
return ERROR_STATE;
}
if (frameType < SdlPacket.FRAME_TYPE_CONTROL || frameType > SdlPacket.FRAME_TYPE_CONSECUTIVE) {
return ERROR_STATE;
}
return SERVICE_TYPE_STATE;
case SERVICE_TYPE_STATE:
serviceType=(int)(rawByte & 0xFF);
return CONTROL_FRAME_INFO_STATE;
case CONTROL_FRAME_INFO_STATE:
controlFrameInfo=(int)(rawByte & 0xFF);
switch (frameType) {
case SdlPacket.FRAME_TYPE_CONTROL:
break;
case SdlPacket.FRAME_TYPE_SINGLE:
case SdlPacket.FRAME_TYPE_FIRST:
if (controlFrameInfo != 0x00) {
return ERROR_STATE;
}
break;
case SdlPacket.FRAME_TYPE_CONSECUTIVE:
break;
default :
return ERROR_STATE;
}
return SESSION_ID_STATE;
case SESSION_ID_STATE:
sessionId=(int)(rawByte & 0xFF);
return DATA_SIZE_1_STATE;
case DATA_SIZE_1_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 24;
return DATA_SIZE_2_STATE;
case DATA_SIZE_2_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 16;
return DATA_SIZE_3_STATE;
case DATA_SIZE_3_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 8;
return DATA_SIZE_4_STATE;
case DATA_SIZE_4_STATE:
dataLength+=((int)rawByte) & 0xFF;
switch (frameType) {
case SdlPacket.FRAME_TYPE_SINGLE:
case SdlPacket.FRAME_TYPE_CONSECUTIVE:
break;
case SdlPacket.FRAME_TYPE_CONTROL:
if (version == 1 && controlFrameInfo == SdlPacket.FRAME_INFO_START_SERVICE) {
if (dataLength == 0) {
return FINISHED_STATE;
}
payload=new byte[dataLength];
dumpSize=dataLength;
return DATA_PUMP_STATE;
}
break;
case SdlPacket.FRAME_TYPE_FIRST:
if (dataLength == FIRST_FRAME_DATA_SIZE) {
break;
}
default :
return ERROR_STATE;
}
return MESSAGE_1_STATE;
case MESSAGE_1_STATE:
messageId+=((int)(rawByte & 0xFF)) << 24;
return MESSAGE_2_STATE;
case MESSAGE_2_STATE:
messageId+=((int)(rawByte & 0xFF)) << 16;
return MESSAGE_3_STATE;
case MESSAGE_3_STATE:
messageId+=((int)(rawByte & 0xFF)) << 8;
return MESSAGE_4_STATE;
case MESSAGE_4_STATE:
messageId+=((int)rawByte) & 0xFF;
if (dataLength == 0) {
return FINISHED_STATE;
}
payload=new byte[dataLength];
dumpSize=dataLength;
return DATA_PUMP_STATE;
case DATA_PUMP_STATE:
payload[dataLength - dumpSize]=rawByte;
dumpSize--;
if (dumpSize > 0) {
return DATA_PUMP_STATE;
}
 else if (dumpSize == 0) {
return FINISHED_STATE;
}
 else {
return ERROR_STATE;
}
case FINISHED_STATE:
default :
return ERROR_STATE;
}
}

Fixed version (ground truth):
private int transitionOnInput(byte rawByte,int state){
switch (state) {
case START_STATE:
    version=(rawByte & (byte)VERSION_MASK) >> 4;
  if (version == 0) {
    return ERROR_STATE;
  }
compression=(1 == ((rawByte & (byte)COMPRESSION_MASK) >> 3));
frameType=rawByte & (byte)FRAME_TYPE_MASK;
switch (version) {
case 0:
if (frameType != SdlPacket.FRAME_TYPE_CONTROL) {
return ERROR_STATE;
}
case 1:
case 2:
break;
default :
return ERROR_STATE;
}
if (frameType < SdlPacket.FRAME_TYPE_CONTROL || frameType > SdlPacket.FRAME_TYPE_CONSECUTIVE) {
return ERROR_STATE;
}
return SERVICE_TYPE_STATE;
case SERVICE_TYPE_STATE:
serviceType=(int)(rawByte & 0xFF);
return CONTROL_FRAME_INFO_STATE;
case CONTROL_FRAME_INFO_STATE:
controlFrameInfo=(int)(rawByte & 0xFF);
switch (frameType) {
case SdlPacket.FRAME_TYPE_CONTROL:
break;
case SdlPacket.FRAME_TYPE_SINGLE:
case SdlPacket.FRAME_TYPE_FIRST:
if (controlFrameInfo != 0x00) {
return ERROR_STATE;
}
break;
case SdlPacket.FRAME_TYPE_CONSECUTIVE:
break;
default :
return ERROR_STATE;
}
return SESSION_ID_STATE;
case SESSION_ID_STATE:
sessionId=(int)(rawByte & 0xFF);
return DATA_SIZE_1_STATE;
case DATA_SIZE_1_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 24;
return DATA_SIZE_2_STATE;
case DATA_SIZE_2_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 16;
return DATA_SIZE_3_STATE;
case DATA_SIZE_3_STATE:
dataLength+=((int)(rawByte & 0xFF)) << 8;
return DATA_SIZE_4_STATE;
case DATA_SIZE_4_STATE:
dataLength+=((int)rawByte) & 0xFF;
switch (frameType) {
case SdlPacket.FRAME_TYPE_SINGLE:
case SdlPacket.FRAME_TYPE_CONSECUTIVE:
break;
case SdlPacket.FRAME_TYPE_CONTROL:
if (version == 1 && controlFrameInfo == SdlPacket.FRAME_INFO_START_SERVICE) {
if (dataLength == 0) {
return FINISHED_STATE;
}
payload=new byte[dataLength];
dumpSize=dataLength;
return DATA_PUMP_STATE;
}
break;
case SdlPacket.FRAME_TYPE_FIRST:
if (dataLength == FIRST_FRAME_DATA_SIZE) {
break;
}
default :
return ERROR_STATE;
}
if (version == 1) {
if (dataLength == 0) {
return FINISHED_STATE;
}
payload=new byte[dataLength];
dumpSize=dataLength;
return DATA_PUMP_STATE;
}
 else {
return MESSAGE_1_STATE;
}
case MESSAGE_1_STATE:
messageId+=((int)(rawByte & 0xFF)) << 24;
return MESSAGE_2_STATE;
case MESSAGE_2_STATE:
messageId+=((int)(rawByte & 0xFF)) << 16;
return MESSAGE_3_STATE;
case MESSAGE_3_STATE:
messageId+=((int)(rawByte & 0xFF)) << 8;
return MESSAGE_4_STATE;
case MESSAGE_4_STATE:
messageId+=((int)rawByte) & 0xFF;
if (dataLength == 0) {
return FINISHED_STATE;
}
payload=new byte[dataLength];
dumpSize=dataLength;
return DATA_PUMP_STATE;
case DATA_PUMP_STATE:
payload[dataLength - dumpSize]=rawByte;
dumpSize--;
if (dumpSize > 0) {
return DATA_PUMP_STATE;
}
 else if (dumpSize == 0) {
return FINISHED_STATE;
}
 else {
return ERROR_STATE;
}
case FINISHED_STATE:
default :
return ERROR_STATE;
}
}