Program: 156158
Project: 156158
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(1);
  int type=buf.readUnsignedByte();
  buf.readUnsignedByte();
  if (type == MSG_LOGIN) {
    if (identify(readImei(buf),channel)) {
      sendResponse(channel,type);
    }
  }
 else   if (hasDeviceId() && type == MSG_STATUS) {
    sendResponse(channel,type);
  }
 else   if (hasDeviceId() && type == MSG_GPS_LBS_STATUS) {
    Position position=new Position();
    position.setDeviceId(getDeviceId());
    position.setProtocol(getProtocolName());
    Calendar time=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
    time.clear();
    time.set(Calendar.YEAR,2000 + buf.readUnsignedByte());
    time.set(Calendar.MONTH,buf.readUnsignedByte() - 1);
    time.set(Calendar.DAY_OF_MONTH,buf.readUnsignedByte());
    time.set(Calendar.HOUR_OF_DAY,buf.readUnsignedByte());
    time.set(Calendar.MINUTE,buf.readUnsignedByte());
    time.set(Calendar.SECOND,buf.readUnsignedByte());
    position.setTime(time.getTime());
    int gpsLength=buf.readUnsignedByte();
    position.set(Event.KEY_SATELLITES,gpsLength & 0xf);
    buf.skipBytes(1);
    double latitude=buf.readUnsignedInt() / 600000.0;
    double longitude=buf.readUnsignedInt() / 600000.0;
    position.setSpeed(buf.readUnsignedByte() * 1.0);
    int union=buf.readUnsignedShort();
    position.setCourse(union & 0x03FF);
    position.setValid((union & 0x1000) != 0);
    if ((union & 0x0400) != 0)     latitude=-latitude;
    if ((union & 0x0800) != 0)     longitude=-longitude;
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    if ((union & 0x4000) != 0) {
      position.set("String_Node_Str",(union & 0x8000) != 0);
    }
    position.set(Event.KEY_LAC,buf.readUnsignedShort());
    position.set(Event.KEY_CELL,buf.readUnsignedMedium());
    position.set(Event.KEY_ALARM,true);
    int flags=buf.readUnsignedByte();
    position.set("String_Node_Str",(flags & 0x2) != 0);
    position.set(Event.KEY_POWER,buf.readUnsignedByte());
    position.set(Event.KEY_GSM,buf.readUnsignedByte());
    return position;
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(1);
  int type=buf.readUnsignedByte();
  buf.readUnsignedByte();
  if (type == MSG_LOGIN) {
    if (identify(readImei(buf),channel)) {
      sendResponse(channel,type);
    }
  }
 else   if (hasDeviceId() && type == MSG_STATUS) {
    sendResponse(channel,type);
  }
 else   if (hasDeviceId() && type == MSG_GPS_LBS_STATUS) {
    Position position=new Position();
    position.setDeviceId(getDeviceId());
    position.setProtocol(getProtocolName());
    Calendar time=Calendar.getInstance(TimeZone.getTimeZone("String_Node_Str"));
    time.clear();
    time.set(Calendar.YEAR,2000 + buf.readUnsignedByte());
    time.set(Calendar.MONTH,buf.readUnsignedByte() - 1);
    time.set(Calendar.DAY_OF_MONTH,buf.readUnsignedByte());
    time.set(Calendar.HOUR_OF_DAY,buf.readUnsignedByte());
    time.set(Calendar.MINUTE,buf.readUnsignedByte());
    time.set(Calendar.SECOND,buf.readUnsignedByte());
    position.setTime(time.getTime());
    int gpsLength=buf.readUnsignedByte();
    position.set(Event.KEY_SATELLITES,gpsLength & 0xf);
    buf.skipBytes(1);
    double latitude=buf.readUnsignedInt() / 600000.0;
    double longitude=buf.readUnsignedInt() / 600000.0;
    position.setSpeed(buf.readUnsignedByte() * 1.0);
    int union=buf.readUnsignedShort();
    position.setCourse(union & 0x03FF);
    position.setValid((union & 0x1000) != 0);
    if ((union & 0x0400) != 0) {
      latitude=-latitude;
    }
    if ((union & 0x0800) != 0) {
      longitude=-longitude;
    }
    position.setLatitude(latitude);
    position.setLongitude(longitude);
    if ((union & 0x4000) != 0) {
      position.set("String_Node_Str",(union & 0x8000) != 0);
    }
    position.set(Event.KEY_LAC,buf.readUnsignedShort());
    position.set(Event.KEY_CELL,buf.readUnsignedMedium());
    position.set(Event.KEY_ALARM,true);
    int flags=buf.readUnsignedByte();
    position.set("String_Node_Str",(flags & 0x2) != 0);
    position.set(Event.KEY_POWER,buf.readUnsignedByte());
    position.set(Event.KEY_GSM,buf.readUnsignedByte());
    return position;
  }
  return null;
}