aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_util.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-10-16 01:02:15 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-10-16 01:02:15 -0700
commit3c5d5b344ee945b99e4bb16a44af6f293601813d (patch)
treefa281ccd0dbc09de55ead86ae3f888e52f684477 /parse_util.cpp
parent4980959fcea76cf42170836f5c8a0657487cac90 (diff)
Fix for buffer overflows identified by libgmalloc
Diffstat (limited to 'parse_util.cpp')
-rw-r--r--parse_util.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/parse_util.cpp b/parse_util.cpp
index 2f95a3e2..5d8a1b1d 100644
--- a/parse_util.cpp
+++ b/parse_util.cpp
@@ -260,8 +260,7 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
/* No subshell found, all done */
break;
}
-
- /* Intrepret NULL to mean the end */
+ /* Interpret NULL to mean the end */
if (end == NULL)
{
end = const_cast<wchar_t *>(buff) + bufflen;
@@ -273,6 +272,9 @@ void parse_util_cmdsubst_extent(const wchar_t *buff, size_t cursor_pos, const wc
begin++;
ap = begin;
bp = end;
+ /* pos is where to begin looking for the next one. But if we reached the end there's no next one. */
+ if (begin >= end)
+ break;
pos = begin + 1;
}
else if (begin >= cursor)