aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2015-03-13 13:50:25 +1100
committerNeil <nyamatongwe@gmail.com>2015-03-13 13:50:25 +1100
commit751585656e3a2ee16d28d01a732fc5ed3bd349c9 (patch)
tree8c933a36d226b6d38cbb9af935e09ce72d8ca0cc
parenta3b272a89f40f8998cbb8b2637e5ed56a7d24f2d (diff)
downloadscintilla-mirror-751585656e3a2ee16d28d01a732fc5ed3bd349c9.tar.gz
Truncate elements that are near to maxItemLen to avoid possibility of writing
outside bounds. Also avoids warning for use of strncpy.
-rw-r--r--src/AutoComplete.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index d154a913a..27eed53b9 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -167,7 +167,9 @@ void AutoComplete::SetList(const char *list) {
char item[maxItemLen];
for (size_t i = 0; i < sortMatrix.size(); ++i) {
int wordLen = IndexSort.indices[sortMatrix[i] * 2 + 2] - IndexSort.indices[sortMatrix[i] * 2];
- strncpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
+ if (wordLen > maxItemLen-2)
+ wordLen = maxItemLen - 2;
+ memcpy(item, list + IndexSort.indices[sortMatrix[i] * 2], wordLen);
if ((i+1) == sortMatrix.size()) {
// Last item so remove separator if present
if ((wordLen > 0) && (item[wordLen-1] == separator))