summaryrefslogtreecommitdiff
path: root/src/console_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-10-22 19:12:10 +0000
committersmatz <smatz@openttd.org>2008-10-22 19:12:10 +0000
commitbc1d994f6c3a1f81b2d5c71a4b656bab4e776d81 (patch)
tree43f6f4d436dced1e168f6a66c84f0027a6db24bd /src/console_gui.cpp
parent852940b45b6ce895998e8455564d5a47bceddb5b (diff)
downloadopenttd-bc1d994f6c3a1f81b2d5c71a4b656bab4e776d81.tar.xz
(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
Diffstat (limited to 'src/console_gui.cpp')
-rw-r--r--src/console_gui.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/console_gui.cpp b/src/console_gui.cpp
index 8d4dfc2cf..baa537322 100644
--- a/src/console_gui.cpp
+++ b/src/console_gui.cpp
@@ -133,7 +133,7 @@ IConsoleModes _iconsole_mode;
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 @@ void IConsoleGUIInit()
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 @@ static void IConsoleHistoryNavigate(int direction)
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);
}