From 295af8f574d4e0ca900ce851802fc3bc9474ba03 Mon Sep 17 00:00:00 2001 From: ipkpjersi Date: Sat, 30 Dec 2023 21:45:07 -0500 Subject: [PATCH 1/2] Fixed dueling NPE Why was this null? Right clicking player and sending duel request via "Challenge" option produces an NPE, because packet is null, but ChallengePlayer checks packet.getOpcode without checking if packet is not null --- .../src/main/java/com/rs2/net/packets/impl/AttackPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/AttackPlayer.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/AttackPlayer.java index 74d00cabc..84ae35be9 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/AttackPlayer.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/AttackPlayer.java @@ -32,7 +32,7 @@ public void processPacket(Player player, Packet packet) { } if (player.inDuelArena() && !player.duelingArena()) { - player.getChallengePlayer().processPacket(player, null); + player.getChallengePlayer().processPacket(player, packet); } if (player.respawnTimer > 0) { From 4548d5ad9fb09c8462316ec831eafad074abda13 Mon Sep 17 00:00:00 2001 From: ipkpjersi Date: Sun, 31 Dec 2023 11:03:19 -0500 Subject: [PATCH 2/2] Added bounds check We don't know if we will receive good data so might as well check it. --- .../src/main/java/com/rs2/net/packets/impl/ChallengePlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChallengePlayer.java b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChallengePlayer.java index 6b2fef485..9ffcca6be 100644 --- a/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChallengePlayer.java +++ b/2006Scape Server/src/main/java/com/rs2/net/packets/impl/ChallengePlayer.java @@ -15,7 +15,7 @@ public void processPacket(Player player, Packet packet) { switch (packet.getOpcode()) { case 128: int answerPlayer = packet.readUnsignedWord(); - if(PlayerHandler.players[answerPlayer] == null || answerPlayer == player.playerId) + if(answerPlayer < 0 || answerPlayer > PlayerHandler.players.length - 1 || PlayerHandler.players[answerPlayer] == null || answerPlayer == player.playerId) return; if (player.duelingArena() || player.duelStatus == 5) {