Huawei: Fix OOM when raw data is received instead of TLV

This commit is contained in:
José Rebelo
2026-05-09 18:45:56 +01:00
parent 2519ed76d7
commit ccf87aa54d
@@ -132,6 +132,11 @@ public class HuaweiTLV {
VarInt varInt = new VarInt(buffer, offset + parsed); VarInt varInt = new VarInt(buffer, offset + parsed);
int size = varInt.dValue; int size = varInt.dValue;
parsed += varInt.size; parsed += varInt.size;
if (size < 0 || size > length - parsed) {
throw new ArrayIndexOutOfBoundsException(
"TLV element size " + size + " exceeds remaining buffer length " + (length - parsed)) {
};
}
byte[] value = new byte[size]; byte[] value = new byte[size];
System.arraycopy(buffer, offset + parsed, value, 0, size); System.arraycopy(buffer, offset + parsed, value, 0, size);
put(tag, value); put(tag, value);