(svn r4314) -Fix: a buffer overflow of the chat box introduced in r1263. Don't tell the Textbuf an arbitrary number as size of the string buffer, but the real lengthof() it
authortron
Fri, 07 Apr 2006 09:07:53 +0000
changeset 3469 3ea3d6e1e611
parent 3468 ec6463161999
child 3470 cd704e52732f
(svn r4314) -Fix: a buffer overflow of the chat box introduced in r1263. Don't tell the Textbuf an arbitrary number as size of the string buffer, but the real lengthof() it
gui.h
main_gui.c
network_gui.c
--- a/gui.h	Fri Apr 07 09:00:57 2006 +0000
+++ b/gui.h	Fri Apr 07 09:07:53 2006 +0000
@@ -124,7 +124,7 @@
 
 /* network gui */
 void ShowNetworkGameWindow(void);
-void ShowChatWindow(int maxlen);
+void ShowChatWindow(void);
 
 /* bridge_gui.c */
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
--- a/main_gui.c	Fri Apr 07 09:00:57 2006 +0000
+++ b/main_gui.c	Fri Apr 07 09:07:53 2006 +0000
@@ -332,7 +332,7 @@
 {
 	_rename_id = desttype + (dest << 8);
 	_rename_what = 2;
-	ShowChatWindow(150);
+	ShowChatWindow();
 }
 
 void ShowNetworkGiveMoneyWindow(byte player)
--- a/network_gui.c	Fri Apr 07 09:00:57 2006 +0000
+++ b/network_gui.c	Fri Apr 07 09:07:53 2006 +0000
@@ -1545,7 +1545,7 @@
 	ChatWindowWndProc
 };
 
-void ShowChatWindow(int maxlen)
+void ShowChatWindow(void)
 {
 	Window *w;
 
@@ -1560,7 +1560,7 @@
 	WP(w,querystr_d).wnd_class = WC_MAIN_TOOLBAR;
 	WP(w,querystr_d).wnd_num = 0;
 	WP(w,querystr_d).text.caret = false;
-	WP(w,querystr_d).text.maxlength = maxlen;
+	WP(w,querystr_d).text.maxlength = lengthof(_edit_str_buf);
 	WP(w,querystr_d).text.maxwidth = w->widget[1].right - w->widget[1].left - 2; // widget[1] is the "text box"
 	WP(w,querystr_d).text.buf = _edit_str_buf;
 	UpdateTextBufferSize(&WP(w, querystr_d).text);