From 912a68effa816c7f4ee436464bf236d889294928 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 4 Aug 2021 12:54:49 -0400 Subject: [PATCH] http service: add pets list length check 0 length lists cause a redis exception from sadd, which I think is not being handled correctly by jedis and leaking the error into further commands --- .../java/net/runelite/http/service/chat/ChatController.java | 6 ++++++ .../client/plugins/chatcommands/ChatCommandsPlugin.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/http-service/src/main/java/net/runelite/http/service/chat/ChatController.java b/http-service/src/main/java/net/runelite/http/service/chat/ChatController.java index 65f4acfa1a..954c90e94b 100644 --- a/http-service/src/main/java/net/runelite/http/service/chat/ChatController.java +++ b/http-service/src/main/java/net/runelite/http/service/chat/ChatController.java @@ -51,6 +51,7 @@ public class ChatController private static final Pattern STRING_VALIDATION = Pattern.compile("[^a-zA-Z0-9' -]"); private static final int STRING_MAX_LENGTH = 50; private static final int MAX_LAYOUT_ROOMS = 16; + private static final int MAX_PETS = 256; private final Cache killCountCache = CacheBuilder.newBuilder() .expireAfterWrite(2, TimeUnit.MINUTES) @@ -251,6 +252,11 @@ public class ChatController @PostMapping("/pets") public void submitPetList(@RequestParam String name, @RequestBody int[] petList) { + if (petList.length == 0 || petList.length > MAX_PETS) + { + return; + } + chatService.setPetList(name, petList); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 1c48b810cf..09610e774e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -1238,7 +1238,10 @@ public class ChatCommandsPlugin extends Plugin try { List petList = getPetList().stream().map(Pet::getIconID).collect(Collectors.toList()); - chatClient.submitPetList(playerName, petList); + if (!petList.isEmpty()) + { + chatClient.submitPetList(playerName, petList); + } } catch (Exception ex) {