From e57fbff28c1175d4536e487a1c1f877436b3f0c2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 21 Mar 2023 00:16:03 +0000 Subject: [PATCH] ItemStackRequestExecutor: added a sanity check for recipe repetitions --- src/network/mcpe/handler/ItemStackRequestExecutor.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/network/mcpe/handler/ItemStackRequestExecutor.php b/src/network/mcpe/handler/ItemStackRequestExecutor.php index df66f49389..3aa751f27d 100644 --- a/src/network/mcpe/handler/ItemStackRequestExecutor.php +++ b/src/network/mcpe/handler/ItemStackRequestExecutor.php @@ -211,6 +211,12 @@ final class ItemStackRequestExecutor{ if($repetitions < 1){ //TODO: upper bound? throw new ItemStackRequestProcessException("Cannot craft a recipe less than 1 time"); } + if($repetitions > 256){ + //TODO: we can probably lower this limit to 64, but I'm unsure if there are cases where the client may + //request more than 64 repetitions of a recipe. + //It's already hard-limited to 256 repetitions in the protocol, so this is just a sanity check. + throw new ItemStackRequestProcessException("Cannot craft a recipe more than 256 times"); + } $craftingManager = $this->player->getServer()->getCraftingManager(); $recipe = $craftingManager->getCraftingRecipeFromIndex($recipeId); if($recipe === null){