Program: 53274
Project: 53274
Buggy source:
/** 
 * Reserved for internal use.
 */
final byte[][] generateMessage(Object name,int parameterCount,byte[] data,ObjectType interfaceClass,int AttributeOrdinal,Command cmd){
  if (getLimits().getMaxInfoRX() == null) {
    throw new GXDLMSException("String_Node_Str");
  }
  java.nio.ByteBuffer buff;
  if (name instanceof byte[]) {
    buff=java.nio.ByteBuffer.wrap((byte[])name);
  }
 else {
    if (name == null) {
      buff=java.nio.ByteBuffer.wrap(data);
    }
 else     if (getUseLogicalNameReferencing()) {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(20 + len);
      if (cmd == Command.GetRequest || cmd == Command.SetRequest || cmd == Command.MethodRequest) {
        buff.putShort((short)interfaceClass.getValue());
        String[] items=((String)name).split("String_Node_Str",-1);
        if (items.length != 6) {
          throw new GXDLMSException("String_Node_Str");
        }
        for (        String it : items) {
          buff.put((byte)(Short.parseShort(it) & 0xFF));
        }
        buff.put((byte)AttributeOrdinal);
        if (data == null || data.length == 0) {
          buff.put((byte)0);
        }
 else {
          buff.put((byte)1);
        }
      }
    }
 else {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(11 + len);
      if (name.getClass().isArray()) {
        for (int pos=0; pos != Array.getLength(name); ++pos) {
          Object it=Array.get(name,pos);
          buff.put((byte)2);
          int base_address=((Number)it).shortValue() & 0xFFFF;
          base_address+=((AttributeOrdinal - 1) * 8);
          buff.putShort((short)base_address);
        }
      }
 else {
        buff.put((byte)1);
      }
      if (cmd == Command.ReadResponse || cmd == Command.WriteResponse) {
        buff.put((byte)0x0);
      }
 else {
        buff.put((byte)parameterCount);
        int base_address=GXCommon.intValue(name);
        if (cmd == Command.MethodRequest) {
          base_address+=AttributeOrdinal;
        }
 else {
          base_address+=((AttributeOrdinal - 1) * 8);
        }
        buff.putShort((short)base_address);
      }
    }
    if (data != null && data.length != 0) {
      buff.put(data);
    }
  }
  return splitToBlocks(buff,cmd);
}

Fixed version (ground truth):
/** 
 * Reserved for internal use.
 */
final byte[][] generateMessage(Object name,int parameterCount,byte[] data,ObjectType interfaceClass,int AttributeOrdinal,Command cmd){
  if (getLimits().getMaxInfoRX() == null) {
    throw new GXDLMSException("String_Node_Str");
  }
  java.nio.ByteBuffer buff;
  if (name instanceof byte[]) {
    buff=java.nio.ByteBuffer.wrap((byte[])name);
  }
 else {
    if (name == null) {
      buff=java.nio.ByteBuffer.wrap(data);
    }
 else     if (getUseLogicalNameReferencing()) {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(20 + len);
      if (cmd == Command.GetRequest || cmd == Command.SetRequest || cmd == Command.MethodRequest) {
        buff.putShort((short)interfaceClass.getValue());
        String[] items=((String)name).split("String_Node_Str",-1);
        if (items.length != 6) {
          throw new GXDLMSException("String_Node_Str");
        }
        for (        String it : items) {
          buff.put((byte)(Short.parseShort(it) & 0xFF));
        }
        buff.put((byte)AttributeOrdinal);
        if (data == null || data.length == 0 || cmd == Command.SetRequest) {
          buff.put((byte)0);
        }
 else {
          buff.put((byte)1);
        }
      }
    }
 else {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(11 + len);
      if (name.getClass().isArray()) {
        for (int pos=0; pos != Array.getLength(name); ++pos) {
          Object it=Array.get(name,pos);
          buff.put((byte)2);
          int base_address=((Number)it).shortValue() & 0xFFFF;
          base_address+=((AttributeOrdinal - 1) * 8);
          buff.putShort((short)base_address);
        }
      }
 else {
        buff.put((byte)1);
      }
      if (cmd == Command.ReadResponse || cmd == Command.WriteResponse) {
        buff.put((byte)0x0);
      }
 else {
        buff.put((byte)parameterCount);
        int base_address=GXCommon.intValue(name);
        if (cmd == Command.MethodRequest) {
          base_address+=AttributeOrdinal;
        }
 else {
          base_address+=((AttributeOrdinal - 1) * 8);
        }
        buff.putShort((short)base_address);
      }
    }
    if (data != null && data.length != 0) {
      buff.put(data);
    }
  }
  return splitToBlocks(buff,cmd);
}