Fix possible buffer overflow in missionFlyTransportersIn and getLandingX/Y.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7841 4a71c877-e1ca-e34f-864e-861f7616d084
master
Guangcong Luo 2009-07-13 21:10:31 +00:00 committed by Git SVN Gateway
parent d5dfdc17e0
commit a31465c75d
1 changed files with 14 additions and 0 deletions

View File

@ -633,6 +633,12 @@ void missionFlyTransportersIn( SDWORD iPlayer, BOOL bTrackTransporter )
SDWORD iLandX, iLandY, iDx, iDy;
double fR;
if ((unsigned int)iPlayer >= 8)
{
debug( LOG_ERROR, "Flying nonexistent player %d's transporters in", iPlayer);
return;
}
bTrackingTransporter = bTrackTransporter;
iLandX = getLandingX(iPlayer);
@ -2986,6 +2992,10 @@ BOOL withinLandingZone(UDWORD x, UDWORD y)
UWORD getLandingX( SDWORD iPlayer )
{
ASSERT( iPlayer<MAX_NOGO_AREAS, "getLandingX: player %d out of range", iPlayer );
if ((unsigned int) iPlayer > 8)
{
iPlayer = 8;
}
return (UWORD)world_coord((sLandingZone[iPlayer].x1 + (sLandingZone[iPlayer].x2 -
sLandingZone[iPlayer].x1)/2));
}
@ -2994,6 +3004,10 @@ UWORD getLandingX( SDWORD iPlayer )
UWORD getLandingY( SDWORD iPlayer )
{
ASSERT( iPlayer<MAX_NOGO_AREAS, "getLandingY: player %d out of range", iPlayer );
if ((unsigned int) iPlayer > 8)
{
iPlayer = 8;
}
return (UWORD)world_coord((sLandingZone[iPlayer].y1 + (sLandingZone[iPlayer].y2 -
sLandingZone[iPlayer].y1)/2));
}