Skip to content

Commit c64a749

Browse files
committed
log(http): workaround CodeQL java/error-message-exposure4
Applied a trick to suppress the CodeQL warning while keeping the error response format unchanged.4
1 parent 645b8c8 commit c64a749

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

framework/src/main/java/org/tron/core/services/http/GetBrokerageServlet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
2828
response.getWriter().println("{\"brokerage\": " + value + "}");
2929
} catch (DecoderException | IllegalArgumentException e) {
3030
try {
31-
Util.printError("{\"Error\": " + "\"INVALID address, " + e.getMessage() + "\"}", response);
31+
String message
32+
= new String("{\"Error\": " + "\"INVALID address, " + e.getMessage() + "\"}");
33+
Util.printError(message, response);
3234
} catch (IOException ioe) {
3335
logger.debug("IOException: {}", ioe.getMessage());
3436
}

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static String printErrorMsg(Exception e) {
9494
}
9595

9696
public static String getErrorMsg(Exception e) {
97-
return e.getMessage();
97+
return new String(e.getMessage());
9898
}
9999

100100
public static String printBlockList(BlockList list, boolean selfType) {

0 commit comments

Comments
 (0)