Debugger: Fix boundary conditions in tab completion
Jeffrey Pfau jeffrey@endrift.com
Thu, 23 Apr 2015 23:54:35 -0700
2 files changed,
6 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -21,6 +21,7 @@ - GBA: Fix hang when loading a savestate if sync to video is enabled
- Debugger: Fix use-after-free in breakpoint clearing code - Util: Fix resource leak in UTF-8 handling code - VFS: Fix resource leaks if some allocations fail + - Debugger: Fix boundary conditions in tab completion Misc: - Qt: Show multiplayer numbers in window title - Qt: Solar sensor can have shortcuts set
M
src/debugger/cli-debugger.c
→
src/debugger/cli-debugger.c
@@ -816,7 +816,7 @@ return CC_ERROR;
} const char* commandPtr; - int cmd = 0, len = 0; + size_t cmd = 0, len = 0; const char* name = 0; for (commandPtr = li->buffer; commandPtr <= li->cursor; ++commandPtr, ++len) { for (; (name = _debuggerCommands[cmd].name); ++cmd) {@@ -832,7 +832,7 @@ }
if (!name) { return CC_ERROR; } - if (_debuggerCommands[cmd + 1].name && name[len - 2] == _debuggerCommands[cmd + 1].name[len - 2]) { + if (_debuggerCommands[cmd + 1].name && strlen(_debuggerCommands[cmd + 1].name) >= len - 1 && name[len - 2] == _debuggerCommands[cmd + 1].name[len - 2]) { --len; const char* next = 0; int i;@@ -841,6 +841,9 @@ if (strncasecmp(name, _debuggerCommands[i].name, len)) {
break; } next = _debuggerCommands[i].name; + } + if (!next) { + return CC_ERROR; } for (; name[len]; ++len) {