mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
fix PacketTeleport sanitizer false positive (#253)
This commit is contained in:
1 parent
ce11a2dcf2
commit
673f832c2d
2 files changed
+22
-6
No files matched your search
@@ -26,27 +26,33 @@ public class PacketUtil {
|
||||
if (!(container instanceof IContainerWithTileEntity)) {
|
||||
Log.LOGGER.warn(
|
||||
Log.securityMarker,
|
||||
"Player {} tried to send {} while not opening correct GUI. Target TileEntity at {}, {}, {}",
|
||||
"Player {} tried to send {} while not opening correct GUI. Target TileEntity {} at {}, {}, {} in {}. Current container {}",
|
||||
player.getGameProfile(),
|
||||
messageClass.getSimpleName(),
|
||||
receivedTile,
|
||||
receivedTile.xCoord,
|
||||
receivedTile.yCoord,
|
||||
receivedTile.zCoord);
|
||||
receivedTile.zCoord,
|
||||
receivedTile.getWorldObj().provider.dimensionId,
|
||||
container);
|
||||
return true;
|
||||
}
|
||||
TileEntity expectedTile = ((IContainerWithTileEntity) container).getTileEntity();
|
||||
if (receivedTile != expectedTile) {
|
||||
Log.LOGGER.warn(
|
||||
Log.securityMarker,
|
||||
"Player {} tried to send {} which attempts to modify setting of TileEntity at {}, {}, {}. Expected: {}, {}, {}",
|
||||
"Player {} tried to send {} which attempts to modify setting of TileEntity at {}, {}, {} in {}. Expected: {}, {}, {} in {}. Current container {}",
|
||||
player.getGameProfile(),
|
||||
messageClass.getSimpleName(),
|
||||
receivedTile.xCoord,
|
||||
receivedTile.yCoord,
|
||||
receivedTile.zCoord,
|
||||
receivedTile.getWorldObj().provider.dimensionId,
|
||||
expectedTile.xCoord,
|
||||
expectedTile.yCoord,
|
||||
expectedTile.zCoord);
|
||||
expectedTile.zCoord,
|
||||
expectedTile.getWorldObj().provider.dimensionId,
|
||||
container);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -59,9 +59,19 @@ public class PacketTeleport extends MessageTileEntity<TileTelePad>
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketTeleport message, MessageContext ctx) {
|
||||
World world = ctx.side.isClient() ? EnderIO.proxy.getClientWorld() : message.getWorld(ctx);
|
||||
boolean isClient = ctx.side.isClient();
|
||||
World world = isClient ? EnderIO.proxy.getClientWorld() : message.getWorld(ctx);
|
||||
TileTelePad te = message.getTileEntity(world);
|
||||
if (PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) return null;
|
||||
if (te == null) return null;
|
||||
if (!isClient) {
|
||||
// BEGIN is the only type of PacketTeleport that originates from a TE GUI
|
||||
if (message.type == Type.BEGIN && PacketUtil.isInvalidPacketForGui(ctx, te, getClass())) {
|
||||
return null;
|
||||
}
|
||||
// TELEPORT is never sent to server
|
||||
if (message.type == Type.TELEPORT) return null;
|
||||
// other types are sent in background without a gui, so no checks
|
||||
}
|
||||
Entity e = world.getEntityByID(message.entityId);
|
||||
switch (message.type) {
|
||||
case BEGIN:
|
||||
|
||||
Reference in new issue
Block a user