Program: 156096
Project: 156096
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  int apiNumber=buf.readUnsignedShort();
  int commandType=buf.readUnsignedByte();
  int messageType=buf.getUnsignedByte(buf.readerIndex()) >> 4;
  boolean needAck=(buf.readUnsignedByte() & 0xf) == 1;
  long mask=defaultMask;
  if (buf.readUnsignedByte() == 4) {
    mask=buf.readUnsignedInt();
  }
  if (apiNumber == 5 && commandType == 2 && messageType == 1 && BitUtil.check(mask,0)) {
    Position position=new Position();
    position.setProtocol(getProtocolName());
    if (BitUtil.check(mask,1)) {
      position.set(Event.KEY_STATUS,buf.readUnsignedInt());
    }
    String id=null;
    if (BitUtil.check(mask,23)) {
      id=buf.toString(buf.readerIndex(),8,Charset.defaultCharset()).trim();
      buf.skipBytes(8);
    }
 else     if (BitUtil.check(mask,2)) {
      id=buf.toString(buf.readerIndex(),22,Charset.defaultCharset()).trim();
      buf.skipBytes(22);
    }
 else {
      Log.warning("String_Node_Str");
      return null;
    }
    if (!identify(id,channel)) {
      return null;
    }
    position.setDeviceId(getDeviceId());
    if (BitUtil.check(mask,3)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,4)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,5)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,7)) {
      buf.readUnsignedByte();
    }
    Calendar time=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
    time.clear();
    if (BitUtil.check(mask,8)) {
      time.set(Calendar.DAY_OF_MONTH,buf.readUnsignedByte());
      time.set(Calendar.MONTH,buf.readUnsignedByte() - 1);
      time.set(Calendar.YEAR,2000 + buf.readUnsignedByte());
    }
    if (BitUtil.check(mask,9)) {
      position.setValid(buf.readUnsignedByte() == 1);
    }
    if (BitUtil.check(mask,10)) {
      position.setLatitude(convertCoordinate(buf.readUnsignedInt()));
    }
    if (BitUtil.check(mask,11)) {
      position.setLongitude(convertCoordinate(buf.readUnsignedInt()));
    }
    if (BitUtil.check(mask,12)) {
      position.setSpeed(buf.readUnsignedShort() / 10.0);
    }
    if (BitUtil.check(mask,13)) {
      position.setCourse(buf.readUnsignedShort() / 10.0);
    }
    if (BitUtil.check(mask,14)) {
      time.set(Calendar.HOUR_OF_DAY,buf.readUnsignedByte());
      time.set(Calendar.MINUTE,buf.readUnsignedByte());
      time.set(Calendar.SECOND,buf.readUnsignedByte());
    }
    position.setTime(time.getTime());
    if (BitUtil.check(mask,15)) {
      position.setAltitude(buf.readMedium());
    }
    if (BitUtil.check(mask,16)) {
      position.set(Event.KEY_SATELLITES,buf.readUnsignedByte());
    }
    if (BitUtil.check(mask,17)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,20)) {
      position.set("String_Node_Str",buf.readUnsignedInt());
    }
    if (BitUtil.check(mask,21)) {
      position.set(Event.KEY_ODOMETER,buf.readUnsignedInt());
    }
    if (BitUtil.check(mask,22)) {
      buf.skipBytes(6);
    }
    if (BitUtil.check(mask,24)) {
      position.set(Event.KEY_POWER,buf.readUnsignedShort() / 1000.0);
    }
    if (BitUtil.check(mask,25)) {
      buf.skipBytes(18);
    }
    if (BitUtil.check(mask,26)) {
      buf.skipBytes(54);
    }
    if (BitUtil.check(mask,28)) {
      position.set(Event.KEY_INDEX,buf.readUnsignedShort());
    }
    return position;
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  int apiNumber=buf.readUnsignedShort();
  int commandType=buf.readUnsignedByte();
  int messageType=BitUtil.from(buf.readUnsignedByte(),4);
  long mask=defaultMask;
  if (buf.readUnsignedByte() == 4) {
    mask=buf.readUnsignedInt();
  }
  if (apiNumber == 5 && commandType == 2 && messageType == 1 && BitUtil.check(mask,0)) {
    Position position=new Position();
    position.setProtocol(getProtocolName());
    if (BitUtil.check(mask,1)) {
      position.set(Event.KEY_STATUS,buf.readUnsignedInt());
    }
    String id;
    if (BitUtil.check(mask,23)) {
      id=buf.toString(buf.readerIndex(),8,Charset.defaultCharset()).trim();
      buf.skipBytes(8);
    }
 else     if (BitUtil.check(mask,2)) {
      id=buf.toString(buf.readerIndex(),22,Charset.defaultCharset()).trim();
      buf.skipBytes(22);
    }
 else {
      Log.warning("String_Node_Str");
      return null;
    }
    if (!identify(id,channel)) {
      return null;
    }
    position.setDeviceId(getDeviceId());
    if (BitUtil.check(mask,3)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,4)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,5)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,7)) {
      buf.readUnsignedByte();
    }
    DateBuilder dateBuilder=new DateBuilder();
    if (BitUtil.check(mask,8)) {
      dateBuilder.setDateReverse(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
    }
    if (BitUtil.check(mask,9)) {
      position.setValid(buf.readUnsignedByte() == 1);
    }
    if (BitUtil.check(mask,10)) {
      position.setLatitude(convertCoordinate(buf.readUnsignedInt()));
    }
    if (BitUtil.check(mask,11)) {
      position.setLongitude(convertCoordinate(buf.readUnsignedInt()));
    }
    if (BitUtil.check(mask,12)) {
      position.setSpeed(buf.readUnsignedShort() / 10.0);
    }
    if (BitUtil.check(mask,13)) {
      position.setCourse(buf.readUnsignedShort() / 10.0);
    }
    if (BitUtil.check(mask,14)) {
      dateBuilder.setTime(buf.readUnsignedByte(),buf.readUnsignedByte(),buf.readUnsignedByte());
    }
    position.setTime(dateBuilder.getDate());
    if (BitUtil.check(mask,15)) {
      position.setAltitude(buf.readMedium());
    }
    if (BitUtil.check(mask,16)) {
      position.set(Event.KEY_SATELLITES,buf.readUnsignedByte());
    }
    if (BitUtil.check(mask,17)) {
      buf.readUnsignedShort();
    }
    if (BitUtil.check(mask,20)) {
      position.set("String_Node_Str",buf.readUnsignedInt());
    }
    if (BitUtil.check(mask,21)) {
      position.set(Event.KEY_ODOMETER,buf.readUnsignedInt());
    }
    if (BitUtil.check(mask,22)) {
      buf.skipBytes(6);
    }
    if (BitUtil.check(mask,24)) {
      position.set(Event.KEY_POWER,buf.readUnsignedShort() / 1000.0);
    }
    if (BitUtil.check(mask,25)) {
      buf.skipBytes(18);
    }
    if (BitUtil.check(mask,26)) {
      buf.skipBytes(54);
    }
    if (BitUtil.check(mask,28)) {
      position.set(Event.KEY_INDEX,buf.readUnsignedShort());
    }
    return position;
  }
  return null;
}