🔒 Validate login response fields
The access level byte and landscape dimensions were trusted from the network without checks.
This commit is contained in:
+11
-1
@@ -163,6 +163,7 @@ procedure TdmNetwork.OnConnectionHandlingPacket(ABuffer: TEnhancedMemoryStream);
|
||||
var
|
||||
subID: Byte;
|
||||
loginState: TLoginState;
|
||||
levelByte: Byte;
|
||||
width, height: Word;
|
||||
serverState: TServerState;
|
||||
begin
|
||||
@@ -189,10 +190,19 @@ begin
|
||||
frmInitialize.Repaint;
|
||||
frmInitialize.lblStatus.Repaint;
|
||||
Application.ProcessMessages;
|
||||
FAccessLevel := TAccessLevel(ABuffer.ReadByte);
|
||||
levelByte := ABuffer.ReadByte;
|
||||
if levelByte in [0, 1, 2, 255] then
|
||||
FAccessLevel := TAccessLevel(accessLevel)
|
||||
else
|
||||
FAccessLevel := alNone;
|
||||
InitGameResourceManager(FDataDir);
|
||||
width := ABuffer.ReadWord;
|
||||
height := ABuffer.ReadWord;
|
||||
if (width = 0) or (height = 0) then
|
||||
begin
|
||||
Disconnect;
|
||||
Exit;
|
||||
end;
|
||||
ResMan.InitLandscape(width, height);
|
||||
ResMan.Landscape.UpdateWriteMap(ABuffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user