From 6eee29a8aa6bd7a6e37e4429c2ad053dff37bb3c Mon Sep 17 00:00:00 2001 From: yoloyyh <1764163852@qq.com> Date: Thu, 17 Oct 2024 20:55:33 +0800 Subject: [PATCH] fix serializer exception --- .../smith/client/message/ClassFilterSerializer.java | 2 +- .../com/security/smith/client/message/TraceSerializer.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/ClassFilterSerializer.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/ClassFilterSerializer.java index 44b996d95..3555aaa91 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/ClassFilterSerializer.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/ClassFilterSerializer.java @@ -31,7 +31,7 @@ public JsonElement serialize(ClassFilter src, Type typeOfSrc, JsonSerializationC private String[] convertStackTrace(StackTraceElement[] stackTrace) { if (stackTrace.length <= 2) - return null; + return new String[0]; StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length); String[] result = new String[elements.length]; diff --git a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/TraceSerializer.java b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/TraceSerializer.java index 8377d8875..d033551cd 100644 --- a/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/TraceSerializer.java +++ b/rasp/jvm/JVMProbe/src/main/java/com/security/smith/client/message/TraceSerializer.java @@ -29,6 +29,8 @@ private String convertRet(Object value) { } private String[] convertArgs(Object[] value) { + if (value == null) + return new String[0]; String[] result = new String[value.length]; for (int i = 0; i < value.length; i++) { result[i] = String.valueOf(value[i]); @@ -37,8 +39,8 @@ private String[] convertArgs(Object[] value) { } private String[] convertStackTrace(StackTraceElement[] stackTrace) { - if (stackTrace.length <= 2) - return null; + if (stackTrace == null || stackTrace.length <= 2) + return new String[0]; StackTraceElement[] elements = Arrays.copyOfRange(stackTrace, 2, stackTrace.length); String[] result = new String[elements.length];