This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b7b42c  Limit the maximum number of lines for the clear command 
(#7911)
5b7b42c is described below

commit 5b7b42ceb54f349d4f74d8b373e92708de26e286
Author: 灼华 <[email protected]>
AuthorDate: Mon May 31 10:16:03 2021 +0800

    Limit the maximum number of lines for the clear command (#7911)
---
 .../dubbo/remoting/telnet/support/command/ClearTelnetHandler.java     | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java
 
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java
index 7fc6afb..378b5f1 100644
--- 
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java
+++ 
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/telnet/support/command/ClearTelnetHandler.java
@@ -29,6 +29,8 @@ import org.apache.dubbo.remoting.telnet.support.Help;
 @Help(parameter = "[lines]", summary = "Clear screen.", detail = "Clear 
screen.")
 public class ClearTelnetHandler implements TelnetHandler {
 
+    private static final int MAX_LINES = 1000;
+
     @Override
     public String telnet(Channel channel, String message) {
         int lines = 100;
@@ -36,7 +38,7 @@ public class ClearTelnetHandler implements TelnetHandler {
             if (!StringUtils.isInteger(message)) {
                 return "Illegal lines " + message + ", must be integer.";
             }
-            lines = Integer.parseInt(message);
+            lines = Math.min(MAX_LINES,Integer.parseInt(message));
         }
         StringBuilder buf = new StringBuilder();
         for (int i = 0; i < lines; i++) {

Reply via email to