Mercurial > hg > openttd
diff src/console_gui.cpp @ 10276:a5286e772120 draft
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
-Fix: one couldn't rename things with too long default/automatic name
-Fix: buffer overflow in console when too long (1024 bytes) command was entered
author | smatz <smatz@openttd.org> |
---|---|
date | Wed, 22 Oct 2008 19:12:10 +0000 |
parents | 12805d675e85 |
children | 045c3016adfe |
line wrap: on
line diff
--- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -133,7 +133,7 @@ static void IConsoleClearCommand() { memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE); - _iconsole_cmdline.length = 0; + _iconsole_cmdline.size = 1; // only terminating zero _iconsole_cmdline.width = 0; _iconsole_cmdline.caretpos = 0; _iconsole_cmdline.caretxoffs = 0; @@ -336,7 +336,7 @@ memset(_iconsole_history, 0, sizeof(_iconsole_history)); _iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it - _iconsole_cmdline.maxlength = ICON_CMDLN_SIZE; + _iconsole_cmdline.maxsize = ICON_CMDLN_SIZE; IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision); IConsolePrint(CC_WHITE, "------------------------------------"); @@ -430,7 +430,7 @@ IConsoleClearCommand(); /* copy history to 'command prompt / bash' */ assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE)); - ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxlength); + ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxsize); UpdateTextBufferSize(&_iconsole_cmdline); }