From 5acc3afcb6f92bc65c7dfb9539b9fb83b4c18b6b Mon Sep 17 00:00:00 2001 From: punchready Date: Fri, 24 Mar 2023 21:39:24 +0100 Subject: [PATCH] Update STR handling to reject for-sure invalid framing values --- TShockAPI/Handlers/SendTileRectHandler.cs | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/TShockAPI/Handlers/SendTileRectHandler.cs b/TShockAPI/Handlers/SendTileRectHandler.cs index 3ff85fea..cb016307 100644 --- a/TShockAPI/Handlers/SendTileRectHandler.cs +++ b/TShockAPI/Handlers/SendTileRectHandler.cs @@ -173,6 +173,7 @@ namespace TShockAPI.Handlers } NetTile newTile = tiles[x, y]; + TileObjectData data; // If the new tile has an associated TileObjectData object, we take the tile and the surrounding tiles that make up the tile object @@ -210,10 +211,26 @@ namespace TShockAPI.Handlers case TileID.ShimmerMonolith: { // Allowed changes + + // Based on empirical tests, these should be some conservative upper bounds for framing values + if (newTile.FrameX != -1 || newTile.FrameY != -1) + { + if (newTile.FrameX is < 0 or > 1000) + { + processed[x, y] = true; + continue; + } + if (newTile.FrameY is < 0 or > 5000) + { + processed[x, y] = true; + continue; + } + } } break; default: { + processed[x, y] = true; continue; } } @@ -233,10 +250,26 @@ namespace TShockAPI.Handlers case TileID.TargetDummy: { // Allowed placements + + // Based on empirical tests, these should be some conservative upper bounds for framing values + if (newTile.FrameX != -1 || newTile.FrameY != -1) + { + if (newTile.FrameX is < 0 or > 1000) + { + processed[x, y] = true; + continue; + } + if (newTile.FrameY is < 0 or > 500) + { + processed[x, y] = true; + continue; + } + } } break; default: { + processed[x, y] = true; continue; } }