diff options
author | Neil <nyamatongwe@gmail.com> | 2015-03-13 13:50:25 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-03-13 13:50:25 +1100 |
commit | 3bb9addd4d1a898eb17a9959f6aaaf56b81cf95b (patch) | |
tree | 3d1c27cd910584264d8b400e90713baeabe899f0 /src | |
parent | 309c0f2bd5c4ec652c4bbcc21cbc76ea5c7430f4 (diff) | |
download | scintilla-mirror-3bb9addd4d1a898eb17a9959f6aaaf56b81cf95b.tar.gz |
Truncate elements that are near to maxItemLen to avoid possibility of writing
outside bounds. Also avoids warning for use of strncpy.
Diffstat (limited to 'src')
-rw-r--r-- | src/AutoComplete.cxx | 4 |
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)) |