Fixed a buffer overflow in comm summary with non-English translations
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2228 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1524,9 +1524,8 @@ DoCommunication (PENCOUNTER_STATE pES)
|
|||||||
TEXT t;
|
TEXT t;
|
||||||
#define DELTA_Y_SUMMARY 8
|
#define DELTA_Y_SUMMARY 8
|
||||||
#define SUMMARY_CHARS (SIS_SCREEN_WIDTH - 34) / 4
|
#define SUMMARY_CHARS (SIS_SCREEN_WIDTH - 34) / 4
|
||||||
#define MAX_SUMMARY_CHARS 52
|
|
||||||
#define MAX_COLS ((SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT - DELTA_Y_SUMMARY) / 8) - 1
|
#define MAX_COLS ((SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT - DELTA_Y_SUMMARY) / 8) - 1
|
||||||
UNICODE buffer[MAX_SUMMARY_CHARS];
|
UNICODE buffer[320]; // SUMMARY_CHARS * 6
|
||||||
UNICODE *temp;
|
UNICODE *temp;
|
||||||
int i;
|
int i;
|
||||||
int col = 0;
|
int col = 0;
|
||||||
@@ -1563,7 +1562,6 @@ DoCommunication (PENCOUNTER_STATE pES)
|
|||||||
temp = curr->text;
|
temp = curr->text;
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
continue;
|
continue;
|
||||||
// fprintf (stderr, "%s\n", temp);
|
|
||||||
while (utf8StringCount (temp) > (unsigned int) SUMMARY_CHARS
|
while (utf8StringCount (temp) > (unsigned int) SUMMARY_CHARS
|
||||||
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
&& !(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||||
{
|
{
|
||||||
@@ -1579,6 +1577,13 @@ DoCommunication (PENCOUNTER_STATE pES)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((unsigned)space_index >= sizeof (buffer))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "DoCommunication() BUG: buffer[%u] "
|
||||||
|
"too small to fit %d bytes\n",
|
||||||
|
sizeof (buffer), space_index);
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
strncpy (buffer, temp, space_index);
|
strncpy (buffer, temp, space_index);
|
||||||
buffer[space_index] = '\0';
|
buffer[space_index] = '\0';
|
||||||
temp += space_index + 1;
|
temp += space_index + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user