mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
修复bytehelper & VlInt中的已知bug
This commit is contained in:
1 parent
227d10a391
commit
2ad446ca2c
29 files changed
+315
-80
No files matched your search
@@ -11,6 +11,7 @@ package component;
|
||||
|
||||
import encoding.*;
|
||||
import util.ByteHelper;
|
||||
import util.ByteHelperException;
|
||||
import util.StringHelper;
|
||||
|
||||
// @Description:
|
||||
@@ -58,7 +59,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
this.identifierBlock=new Block();
|
||||
this.identifierBlock.setType(new VlInt(TLV.TlvIdentifierComponent));
|
||||
this.identifierBlock.setLength(new VlInt(nameComponent.length()+1));
|
||||
byte[] value=new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
byte[] value= new byte[0];
|
||||
try {
|
||||
value = new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
} catch (VlIntException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
value[0]=MarkerString;
|
||||
System.arraycopy(nameComponent.getBytes(),0,value,1,nameComponent.getBytes().length);
|
||||
this.identifierBlock.setValue(value);
|
||||
@@ -74,7 +80,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
this.identifierBlock=new Block();
|
||||
this.identifierBlock.setType(new VlInt(TLV.TlvIdentifierComponent));
|
||||
this.identifierBlock.setLength(new VlInt(new VlInt(intValue).size()+1));
|
||||
byte[] value=new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
byte[] value= new byte[0];
|
||||
try {
|
||||
value = new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
} catch (VlIntException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
value[0]=MarkerNonNegativeInteger;
|
||||
System.arraycopy(new VlInt(intValue).getVlIntBytes(),0,value,1,new VlInt(intValue).size());
|
||||
this.identifierBlock.setValue(value);
|
||||
@@ -90,7 +101,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
this.identifierBlock=new Block();
|
||||
this.identifierBlock.setType(new VlInt(TLV.TlvIdentifierComponent));
|
||||
this.identifierBlock.setLength(new VlInt(arr.length+1));
|
||||
byte[] value=new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
byte[] value= new byte[0];
|
||||
try {
|
||||
value = new byte[this.identifierBlock.getLength().getVlIntValue2Int()];
|
||||
} catch (VlIntException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
value[0]=MarkerByteArray;
|
||||
System.arraycopy(arr,0,value,1,arr.length);
|
||||
this.identifierBlock.setValue(value);
|
||||
@@ -175,7 +191,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
this.identifierBlock=new Block(block);
|
||||
|
||||
//todo:越界问题
|
||||
int length=this.identifierBlock.getLength().getVlIntValue2Int();
|
||||
int length= 0;
|
||||
try {
|
||||
length = this.identifierBlock.getLength().getVlIntValue2Int();
|
||||
} catch (VlIntException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
byte[] value=this.identifierBlock.getValue();
|
||||
|
||||
// 要求TLV-LENGTH至少为1,因为 IdentifierComponent 使用 TLV-VALUE 中的第一个字节作为Marker
|
||||
@@ -190,7 +211,12 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
this.marker=value[0];
|
||||
|
||||
// 根据不同类型的Marker,给不同的成员赋值
|
||||
byte[] v=ByteHelper.getTailBytes(value,1);
|
||||
byte[] v= new byte[0];
|
||||
try {
|
||||
v = ByteHelper.getTailBytes(value,1);
|
||||
} catch (ByteHelperException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(isString()){
|
||||
this.stringValue=new String(v);
|
||||
}else if(isNonNegativeInteger()){
|
||||
|
||||
Reference in new issue
Block a user