add strict STR size checking

This commit is contained in:
punchready 2022-07-26 08:24:46 +02:00
parent abaf414523
commit 681c6de1f7
2 changed files with 4 additions and 18 deletions

View file

@ -445,14 +445,6 @@ namespace TShockAPI.Configuration
[Description("Whether or not to kick users when they surpass the HealOther threshold.")]
public bool KickOnHealOtherThresholdBroken = false;
/// <summary>Disables a player if this number of tiles is present in a Tile Rectangle packet</summary>
[Description("Disables a player if this number of tiles is present in a Tile Rectangle packet")]
public int TileRectangleSizeThreshold = 50;
/// <summary>Whether or not to kick users when they surpass the TileRectangleSize threshold.</summary>
[Description("Whether or not to kick users when they surpass the TileRectangleSize threshold.")]
public bool KickOnTileRectangleSizeThresholdBroken = false;
/// <summary>Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.</summary>
[Description("Whether or not the server should suppress build permission failure warnings from regions, spawn point, or server edit failure.")]
public bool SuppressPermissionFailureNotices = false;

View file

@ -232,7 +232,7 @@ namespace TShockAPI.Handlers
}
}
}
/// <summary>
/// Processes a tile object consisting of multiple tiles from the tile rect packet
/// </summary>
@ -290,12 +290,12 @@ namespace TShockAPI.Handlers
ITile tile = Main.tile[realX, realY];
if (tile.type == TileID.LandMine && !newTile.Active)
if (rectWidth == 1 && rectLength == 1 && tile.type == TileID.LandMine && !newTile.Active)
{
UpdateServerTileState(tile, newTile, TileDataType.Tile);
}
if (tile.type == TileID.WirePipe)
if (rectWidth == 1 && rectLength == 1 && tile.type == TileID.WirePipe)
{
UpdateServerTileState(tile, newTile, TileDataType.Tile);
}
@ -500,15 +500,9 @@ namespace TShockAPI.Handlers
return true;
}
var rectSize = args.Width * args.Length;
if (rectSize > TShock.Config.Settings.TileRectangleSizeThreshold)
if (args.Width > 4 || args.Length > 4) // as of 1.4.3.6 this is the biggest size the client will send in any case
{
TShock.Log.ConsoleDebug("Bouncer / SendTileRect rejected from non-vanilla tilemod from {0}", args.Player.Name);
if (TShock.Config.Settings.KickOnTileRectangleSizeThresholdBroken)
{
args.Player.Kick("Unexpected tile threshold reached");
}
return true;
}