# HG changeset patch # User unc0rr # Date 1180274021 0 # Node ID e3689572bb15d9b29be49b9b3a1b90443f3d2aa2 # Parent ae21b8e86dd9f086903028b2ec388f51357bfb93 - Check for incoming buffer overflow - Fix incorrect position of attack bar in some cases diff -r ae21b8e86dd9 -r e3689572bb15 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Sat May 26 20:47:36 2007 +0000 +++ b/hedgewars/uIO.pas Sun May 27 13:53:41 2007 +0000 @@ -36,10 +36,11 @@ implementation uses uConsole, uConsts, uWorld, uMisc, uLand; const isPonged: boolean = false; + MAXCMDS = 65535; var IPCSock: PTCPSocket = nil; fds: PSDLNet_SocketSet; - extcmd: array[word] of packed record + extcmd: array[0..MAXCMDS] of packed record Time: LongWord; case byte of 1: (len: byte; @@ -89,6 +90,7 @@ else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end; else inc(cmdendpos); + TryDo(cmdendpos <= MAXCMDS, 'Too many commands in queue', true); extcmd[cmdendpos].Time := SDLNet_Read32(@s[byte(s[0]) - 3]); extcmd[cmdendpos].str := s; {$IFDEF DEBUGFILE}AddFileLog('IPC in: '+s[1]+' ticks '+inttostr(extcmd[cmdendpos].Time)+' at '+inttostr(cmdendpos));{$ENDIF} diff -r ae21b8e86dd9 -r e3689572bb15 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sat May 26 20:47:36 2007 +0000 +++ b/hedgewars/uWorld.pas Sun May 27 13:53:41 2007 +0000 @@ -247,8 +247,8 @@ tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do - DrawSprite(sprPower, Gear^.X.Round + system.round(WorldDx + tdx * (24 + i * 2)) - 16, - Gear^.Y.Round + system.round(WorldDy + tdy * (24 + i * 2)) - 12, + DrawSprite(sprPower, hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16, + hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12, i, Surface) end end;