diff --git a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java index 9a83e26..b822db7 100644 --- a/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java +++ b/src/main/java/com/sunyard/sge/database/SydApiBaseFunction.java @@ -124,6 +124,14 @@ public class SydApiBaseFunction implements SydApi { if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } + + if (null == pcData) { + throw new SydApiException("输入内容为 null",19); + } + if ( pcData.length > 1024 ) { + throw new SydApiException("输入内容为空",19); + } + SydApiException le = new SydApiException(-1); updateLastUseTime(); @@ -248,7 +256,15 @@ public class SydApiBaseFunction implements SydApi { if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } - + if (Consts.ECB_ENC == iFlag) { + if ( pcData.length > 1024 ) { + throw new SydApiException("输入内容超长",19); + } + } else { + if ( pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + } updateLastUseTime(); String keyIndex = String.format("%08d", iKeyIndex); SydApiException le = new SydApiException(-1); @@ -318,13 +334,21 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4_BatchData方法接收参数:iKeyIndex:{},pcData元素个数为:{},iFlag:{}", iKeyIndex, pcData.size(), iFlag); } + if (iFlag == Consts.ECB_DEC) { for (byte[] pcdata : pcData) { - if (null == pcData || pcdata.length == 0) { + if (null == pcData || pcdata.length == 0 || pcdata.length > 1040) { + throw new SydApiException(19); + } + } + } else { + for (byte[] pcdata : pcData) { + if (null == pcData || pcdata.length > 1024) { throw new SydApiException(19); } } } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } @@ -722,6 +746,11 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4Mac_ShortData方法接收参数:iKeyIndex:{},pcData:{},iFlag:{}", iKeyIndex, Arrays.toString(pcData)); } + + if ( null == pcData || pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); } @@ -777,6 +806,11 @@ public class SydApiBaseFunction implements SydApi { if (LogFactory.iLogLevel == 3) { log.debug("SYD_SM4Mac_ShortData方法接收参数:{}", iKeyIndex, Arrays.toString(pcData), pcMac); } + + if ( null == pcData || pcData.length > 1040 ) { + throw new SydApiException("输入内容超长",19); + } + if (null == this.hsms || this.hsms.length < 1) { throw new SydApiException(-1); }