From b9f522427f6f9c9dca75e8ed26b7d2cce6b41053 Mon Sep 17 00:00:00 2001 From: Snehil Kumar <51155558+SneakySensei@users.noreply.github.com> Date: Sat, 7 Sep 2024 18:21:25 +0530 Subject: [PATCH] add validation for column --- .../backend/microservices/connect-four/connect-four.routes.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/backend/microservices/connect-four/connect-four.routes.ts b/packages/backend/microservices/connect-four/connect-four.routes.ts index e78461d..15081a9 100644 --- a/packages/backend/microservices/connect-four/connect-four.routes.ts +++ b/packages/backend/microservices/connect-four/connect-four.routes.ts @@ -271,6 +271,10 @@ export const ConnectFourRoutes = async (socket: Socket, io: Namespace) => { return; } + // validate invalid move + if (move.column < -1 || move.column >= ConnectFour.columnCount) + return; + if (gameState.winner_id) { return; }