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
This commit is contained in:
Adam
2021-08-04 12:54:49 -04:00
parent 92e85d5db0
commit 912a68effa
2 changed files with 10 additions and 1 deletions

View File

@@ -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<KillCountKey, Integer> 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);
}