Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore malformed orders instead of crashing. #15554

Merged
merged 1 commit into from Aug 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 19 additions & 5 deletions OpenRA.Game/Network/Order.cs
Expand Up @@ -76,10 +76,12 @@ public CPos TargetLocation

public static Order Deserialize(World world, BinaryReader r)
{
var magic = r.ReadByte();
switch (magic)
try
{
case 0xFF:
var magic = r.ReadByte();
switch (magic)
{
case 0xFF:
{
var order = r.ReadString();
var subjectId = r.ReadUInt32();
Expand Down Expand Up @@ -156,19 +158,31 @@ public static Order Deserialize(World world, BinaryReader r)
return new Order(order, subject, target, targetString, queued, extraLocation, extraData);
}

case 0xfe:
case 0xfe:
{
var name = r.ReadString();
var data = r.ReadString();

return new Order(name, null, false) { IsImmediate = true, TargetString = data };
}

default:
default:
{
Log.Write("debug", "Received unknown order with magic {0}", magic);
return null;
}
}
}
catch (Exception e)
{
Log.Write("debug", "Caught exception while processing order");
Log.Write("debug", e.ToString());

// HACK: this can hopefully go away in the future
Game.Debug("Ignoring malformed order that would have crashed the game");
Game.Debug("Please file a bug report and include the replay from this match");

return null;
}
}

Expand Down