Merge pull request #2529 from drunderscore/feature/bouncer-reject-out-of-bounds-read-sign
Added the `OnSignRead` handler and `SignRead` event, and prevent out of bounds tile access
This commit is contained in:
commit
fdcad65d4d
2 changed files with 56 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace)
|
* Fixed the ability to spawn Zenith projectile with non-original items. (@AgaSpace)
|
||||||
* Added hook `GetDataHandlers.OnNpcTalk` for NpcTalk and a handler for it that stops unregistered and logged out players from interacting with NPCs, preventing them from smuggling or duplicating items via NPC item slots. (@tru321)
|
* Added hook `GetDataHandlers.OnNpcTalk` for NpcTalk and a handler for it that stops unregistered and logged out players from interacting with NPCs, preventing them from smuggling or duplicating items via NPC item slots. (@tru321)
|
||||||
* Fixed the ability to create custom messages with your death (or the death of another player) (@AgaSpace)
|
* Fixed the ability to create custom messages with your death (or the death of another player) (@AgaSpace)
|
||||||
|
* Added the `OnSignRead` handler in `GetDataHandler`, and added the `SignRead` event. Added check to ensure the sign being read is within world bounds `(x >= 0 && y >= 0 && x < Main.maxTilesX && y < Main.maxTilesY)`. (@drunderscore)
|
||||||
|
|
||||||
## TShock 4.5.11
|
## TShock 4.5.11
|
||||||
* Add the new allowed buff TentacleSpike to NPC buff cheat detection bouncer. (@sgkoishi)
|
* Add the new allowed buff TentacleSpike to NPC buff cheat detection bouncer. (@sgkoishi)
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ namespace TShockAPI
|
||||||
{ PacketTypes.PlayerAnimation, HandlePlayerAnimation },
|
{ PacketTypes.PlayerAnimation, HandlePlayerAnimation },
|
||||||
{ PacketTypes.PlayerMana, HandlePlayerMana },
|
{ PacketTypes.PlayerMana, HandlePlayerMana },
|
||||||
{ PacketTypes.PlayerTeam, HandlePlayerTeam },
|
{ PacketTypes.PlayerTeam, HandlePlayerTeam },
|
||||||
|
{ PacketTypes.SignRead, HandleSignRead },
|
||||||
{ PacketTypes.SignNew, HandleSign },
|
{ PacketTypes.SignNew, HandleSign },
|
||||||
{ PacketTypes.LiquidSet, HandleLiquidSet },
|
{ PacketTypes.LiquidSet, HandleLiquidSet },
|
||||||
{ PacketTypes.PlayerBuff, HandlePlayerBuffList },
|
{ PacketTypes.PlayerBuff, HandlePlayerBuffList },
|
||||||
|
|
@ -1187,6 +1188,43 @@ namespace TShockAPI
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For use in a SignRead event
|
||||||
|
/// </summary>
|
||||||
|
public class SignReadEventArgs : GetDataHandledEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// X location of the sign
|
||||||
|
/// </summary>
|
||||||
|
public int X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Y location of the sign
|
||||||
|
/// </summary>
|
||||||
|
public int Y { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sign - Called when a sign is read
|
||||||
|
/// </summary>
|
||||||
|
public static HandlerList<SignReadEventArgs> SignRead = new HandlerList<SignReadEventArgs>();
|
||||||
|
|
||||||
|
private static bool OnSignRead(TSPlayer player, MemoryStream data, int x, int y)
|
||||||
|
{
|
||||||
|
if (SignRead == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var args = new SignReadEventArgs
|
||||||
|
{
|
||||||
|
Player = player,
|
||||||
|
Data = data,
|
||||||
|
X = x,
|
||||||
|
Y = y,
|
||||||
|
};
|
||||||
|
SignRead.Invoke(null, args);
|
||||||
|
return args.Handled;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For use in a Sign event
|
/// For use in a Sign event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3217,6 +3255,23 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HandleSignRead(GetDataHandlerArgs args)
|
||||||
|
{
|
||||||
|
var x = args.Data.ReadInt16();
|
||||||
|
var y = args.Data.ReadInt16();
|
||||||
|
|
||||||
|
if (OnSignRead(args.Player, args.Data, x, y))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (x < 0 || y < 0 || x >= Main.maxTilesX || y >= Main.maxTilesY)
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("GetDataHandlers / HandleSignRead rejected out of bounds {0}", args.Player.Name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool HandleSign(GetDataHandlerArgs args)
|
private static bool HandleSign(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var id = args.Data.ReadInt16();
|
var id = args.Data.ReadInt16();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue