Fixed a buffer overflow when saving a game with too many devices

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3182 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-09-30 23:12:49 +00:00
parent 9925a29c89
commit 0a609ba3f1
5 changed files with 14 additions and 5 deletions
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.7:
- Fixed crash when saving a game into the last slot while having
too many devices on board - Alex
- Allow any sound data format to be graphed by comm oscilloscope; also
auto-adjust the scope for different gain levels (bug #1064) - Alex
- Game settings Quit menu now delegates to F10 quit (bug #462) - Alex
+4 -3
View File
@@ -532,13 +532,13 @@ SelectDevice:
}
SIZE
InventoryDevices (BYTE *pDeviceMap)
InventoryDevices (BYTE *pDeviceMap, COUNT Size)
{
BYTE i;
SIZE DevicesOnBoard;
DevicesOnBoard = 0;
for (i = 0; i < NUM_DEVICES; ++i)
for (i = 0; i < NUM_DEVICES && Size > 0; ++i)
{
BYTE DeviceState;
@@ -630,6 +630,7 @@ InventoryDevices (BYTE *pDeviceMap)
{
*pDeviceMap++ = i;
++DevicesOnBoard;
--Size;
}
}
@@ -641,7 +642,7 @@ Devices (MENU_STATE *pMS)
{
BYTE DeviceMap[NUM_DEVICES];
pMS->first_item.x = InventoryDevices (DeviceMap);
pMS->first_item.x = InventoryDevices (DeviceMap, NUM_DEVICES);
if (pMS->first_item.x)
{
pMS->InputFunc = DoManipulateDevices;
+2 -1
View File
@@ -499,7 +499,8 @@ PrepareSummary (SUMMARY_DESC *SummPtr)
}
}
SummPtr->NumDevices = InventoryDevices (SummPtr->DeviceList);
SummPtr->NumDevices = InventoryDevices (SummPtr->DeviceList,
MAX_EXCLUSIVE_DEVICES);
SummPtr->Flags = GET_GAME_STATE (LANDER_SHIELDS)
| (GET_GAME_STATE (IMPROVED_LANDER_SPEED) << (4 + 0))
+1 -1
View File
@@ -30,7 +30,7 @@ extern BOOLEAN Devices (MENU_STATE *pMS);
extern void DrawCargoStrings (BYTE OldElement, BYTE NewElement);
extern void ShowRemainingCapacity (void);
extern SIZE InventoryDevices (BYTE *pDeviceMap);
extern SIZE InventoryDevices (BYTE *pDeviceMap, COUNT Size);
#endif /* _SHIPCONT_H */
+5
View File
@@ -223,6 +223,11 @@ typedef struct
UNICODE PlanetName[SIS_NAME_SIZE];
} SIS_STATE;
// XXX: Theoretically, a player can have 17 devices on board without
// cheating (18 if never visited the Starbase). We only provide
// room for 16 below, which is not really a problem since this
// is only used for displaying savegame summaries. There is also
// room for only 16 devices on screen.
#define MAX_EXCLUSIVE_DEVICES 16
typedef struct