Program: 156110
Project: 156110
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  if ((buf.getByte(buf.readerIndex()) & 0x80) != 0) {
    int content=buf.readUnsignedByte();
    if ((content & 0x01) != 0) {
      int length=buf.readUnsignedByte();
      long id=0;
      for (int i=0; i < length; i++) {
        int b=buf.readUnsignedByte();
        id=id * 10 + (b >> 4);
        if ((b & 0xf) != 0xf) {
          id=id * 10 + (b & 0xf);
        }
      }
      identify(String.valueOf(id),channel,remoteAddress);
    }
    if ((content & 0x02) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x04) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x08) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x10) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x20) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
  }
  if (!hasDeviceId()) {
    return null;
  }
  int service=buf.readUnsignedByte();
  int type=buf.readUnsignedByte();
  int index=buf.readUnsignedShort();
  if (service == SERVICE_ACKNOWLEDGED) {
    sendResponse(channel,remoteAddress,type,index,0);
  }
  if (type == MSG_EVENT_REPORT || type == MSG_LOCATE_REPORT || type == MSG_MINI_EVENT_REPORT) {
    Position position=new Position();
    position.setDeviceId(getDeviceId());
    position.setProtocol(getProtocolName());
    position.setTime(new Date(buf.readUnsignedInt() * 1000));
    if (type != MSG_MINI_EVENT_REPORT) {
      buf.readUnsignedInt();
    }
    position.setLatitude(buf.readInt() * 0.0000001);
    position.setLongitude(buf.readInt() * 0.0000001);
    if (type != MSG_MINI_EVENT_REPORT) {
      position.setAltitude(buf.readInt() * 0.01);
      position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedInt()));
    }
    position.setCourse(buf.readShort());
    if (type == MSG_MINI_EVENT_REPORT) {
      position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
    }
    if (type == MSG_MINI_EVENT_REPORT) {
      position.set(Event.KEY_SATELLITES,buf.getUnsignedByte(buf.readerIndex()) & 0xf);
      position.setValid((buf.readUnsignedByte() & 0x20) == 0);
    }
 else {
      position.set(Event.KEY_SATELLITES,buf.readUnsignedByte());
      position.setValid((buf.readUnsignedByte() & 0x08) == 0);
    }
    if (type != MSG_MINI_EVENT_REPORT) {
      position.set("String_Node_Str",buf.readUnsignedShort());
      position.set(Event.KEY_GSM,buf.readShort());
    }
    position.set("String_Node_Str",buf.readUnsignedByte());
    if (type != MSG_MINI_EVENT_REPORT) {
      position.set(Event.KEY_HDOP,buf.readUnsignedByte());
    }
    position.set(Event.KEY_INPUT,buf.readUnsignedByte());
    if (type != MSG_MINI_EVENT_REPORT) {
      position.set(Event.KEY_STATUS,buf.readUnsignedByte());
    }
    if (type == MSG_EVENT_REPORT || type == MSG_MINI_EVENT_REPORT) {
      if (type != MSG_MINI_EVENT_REPORT) {
        buf.readUnsignedByte();
      }
      position.set(Event.KEY_EVENT,buf.readUnsignedByte());
    }
    int accCount=buf.readUnsignedByte();
    int accType=accCount >> 6;
    accCount&=0x3f;
    if (type != MSG_MINI_EVENT_REPORT) {
      buf.readUnsignedByte();
    }
    if (accType == 1) {
      buf.readUnsignedInt();
      buf.readUnsignedInt();
    }
    for (int i=0; i < accCount; i++) {
      position.set("String_Node_Str" + i,buf.readUnsignedInt());
    }
    return position;
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  if ((buf.getByte(buf.readerIndex()) & 0x80) != 0) {
    int content=buf.readUnsignedByte();
    if ((content & 0x01) != 0) {
      int length=buf.readUnsignedByte();
      long id=0;
      for (int i=0; i < length; i++) {
        int b=buf.readUnsignedByte();
        id=id * 10 + (b >> 4);
        if ((b & 0xf) != 0xf) {
          id=id * 10 + (b & 0xf);
        }
      }
      identify(String.valueOf(id),channel,remoteAddress);
    }
    if ((content & 0x02) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x04) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x08) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x10) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
    if ((content & 0x20) != 0) {
      buf.skipBytes(buf.readUnsignedByte());
    }
  }
  if (!hasDeviceId()) {
    return null;
  }
  int service=buf.readUnsignedByte();
  int type=buf.readUnsignedByte();
  int index=buf.readUnsignedShort();
  if (service == SERVICE_ACKNOWLEDGED) {
    sendResponse(channel,remoteAddress,type,index,0);
  }
  if (type == MSG_EVENT_REPORT || type == MSG_LOCATE_REPORT || type == MSG_MINI_EVENT_REPORT) {
    return decodePosition(type,buf);
  }
  return null;
}