Fixed the ancient buffer overflows in Memory Watch.
This commit is contained in:
parent
3b531d0d7c
commit
fe64ca3771
|
@ -2242,7 +2242,7 @@ BOOL CALLBACK MemFindCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||
break;
|
||||
case WM_CLOSE:
|
||||
case WM_QUIT:
|
||||
GetDlgItemText(hwndDlg,IDC_MEMVIEWFIND_WHAT,FindTextBox,59);
|
||||
GetDlgItemText(hwndDlg,IDC_MEMVIEWFIND_WHAT,FindTextBox,60);
|
||||
DestroyWindow(hwndDlg);
|
||||
hMemFind = 0;
|
||||
hwndDlg = 0;
|
||||
|
@ -2302,7 +2302,7 @@ void FindNext(){
|
|||
unsigned char data[60];
|
||||
int datasize = 0, i, j, inputc = -1, found;
|
||||
|
||||
if(hMemFind) GetDlgItemText(hMemFind,IDC_MEMVIEWFIND_WHAT,str,59);
|
||||
if(hMemFind) GetDlgItemText(hMemFind,IDC_MEMVIEWFIND_WHAT,str,60);
|
||||
else strcpy(str,FindTextBox);
|
||||
|
||||
for(i = 0;str[i] != 0;i++){
|
||||
|
|
|
@ -72,12 +72,12 @@ extern void RemoveRecentItem(unsigned int which, char**bufferArray, const unsign
|
|||
//Ram change monitor globals-----------------------------------
|
||||
bool RamChangeInitialize = false; //Set true during memw WM_INIT
|
||||
const int MAX_RAMMONITOR = 4; //Maximum number of Ram values that can be monitored
|
||||
char editboxnow[MAX_RAMMONITOR][5]; //current address put into editbox 00
|
||||
char editboxlast[MAX_RAMMONITOR][5]; //last address put into editbox (1 frame ago)
|
||||
char editboxnow[MAX_RAMMONITOR][8]; //current address put into editbox 00
|
||||
char editboxlast[MAX_RAMMONITOR][8]; //last address put into editbox (1 frame ago)
|
||||
int editlast[MAX_RAMMONITOR]; //last address value (1 frame ago)
|
||||
int editnow[MAX_RAMMONITOR]; //current address value
|
||||
unsigned int editcount[MAX_RAMMONITOR]; //Current counter value
|
||||
char editchangem[MAX_RAMMONITOR][5]; //counter converted to string
|
||||
char editchangem[MAX_RAMMONITOR][12]; //counter converted to string
|
||||
|
||||
//-------------------------------------------------
|
||||
|
||||
|
@ -336,7 +336,6 @@ void UpdateMemWatch()
|
|||
TextOut(hdc,0,0,text,strlen(text));
|
||||
SetTextColor(hdc,RGB(0,0,0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,14 +387,14 @@ bool iftextchanged()
|
|||
int i,j;
|
||||
for(i=0;i<NUMWATCHES;i++)
|
||||
{
|
||||
for(j=0;j<LABELLENGTH;j++)
|
||||
for(j=0;j<ADDRESSLENGTH;j++)
|
||||
{
|
||||
if(addresses[i][j] != NULL || labels [i][j] != NULL)
|
||||
if(addresses[i][j] != '\0' || labels [i][j] != '\0')
|
||||
return true;
|
||||
}
|
||||
for(;j<LABELLENGTH;j++)
|
||||
{
|
||||
if(labels[i][j] != NULL)
|
||||
if(labels[i][j] != '\0')
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -445,16 +444,16 @@ static void SaveMemWatch()
|
|||
for(i=0;i<NUMWATCHES;i++)
|
||||
{
|
||||
//Use dummy strings to fill empty slots
|
||||
if(labels[i][0] == 0)
|
||||
{
|
||||
labels[i][0] = '|';
|
||||
labels[i][1] = 0;
|
||||
}
|
||||
if(addresses[i][0] == 0)
|
||||
{
|
||||
addresses[i][0] = '|';
|
||||
addresses[i][1] = 0;
|
||||
}
|
||||
if(labels[i][0] == 0)
|
||||
{
|
||||
labels[i][0] = '|';
|
||||
labels[i][1] = 0;
|
||||
}
|
||||
//spaces can be a problem for scanf so get rid of them
|
||||
TakeOutSpaces(i);
|
||||
fprintf(fp, "%s %s\n", addresses[i], labels[i]);
|
||||
|
@ -476,16 +475,16 @@ static void QuickSaveMemWatch() //Save rather than Save as
|
|||
for(int i=0;i<NUMWATCHES;i++)
|
||||
{
|
||||
//Use dummy strings to fill empty slots
|
||||
if(labels[i][0] == 0)
|
||||
{
|
||||
labels[i][0] = '|';
|
||||
labels[i][1] = 0;
|
||||
}
|
||||
if(addresses[i][0] == 0)
|
||||
{
|
||||
addresses[i][0] = '|';
|
||||
addresses[i][1] = 0;
|
||||
}
|
||||
if(labels[i][0] == 0)
|
||||
{
|
||||
labels[i][0] = '|';
|
||||
labels[i][1] = 0;
|
||||
}
|
||||
//spaces can be a problem for scanf so get rid of them
|
||||
TakeOutSpaces(i);
|
||||
fprintf(fp, "%s %s\n", addresses[i], labels[i]);
|
||||
|
@ -958,11 +957,15 @@ void CreateMemWatch()
|
|||
int i,j;
|
||||
for(i=0;i<NUMWATCHES;i++)
|
||||
{
|
||||
for(j=0;j<LABELLENGTH;j++)
|
||||
for(j=0;j<ADDRESSLENGTH;j++)
|
||||
{
|
||||
addresses[i][j] = 0;
|
||||
labels[i][j] = 0;
|
||||
}
|
||||
for (;j<LABELLENGTH;j++)
|
||||
{
|
||||
labels[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue