From ca1a5ea845c283a9c84fd2ae9f6d152cca354183 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 22 Dec 2013 18:00:45 +1100 Subject: Avoid unsafe strcpy, strncpy, and strcat replacing with safer functions which guaranty termination where possible. --- lexers/LexHTML.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lexers') diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx index bb70fd45b..5ea24d481 100644 --- a/lexers/LexHTML.cxx +++ b/lexers/LexHTML.cxx @@ -16,6 +16,7 @@ #include "Scintilla.h" #include "SciLexer.h" +#include "StringCopy.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -929,9 +930,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty (ch == '$' && chNext == '{') || (ch == '<' && chNext == '/' && chNext2 == '%'))) { if (ch == '%' || ch == '/') - strcpy(makoBlockType, "%"); + StringCopy(makoBlockType, "%"); else if (ch == '$') - strcpy(makoBlockType, "{"); + StringCopy(makoBlockType, "{"); else if (chNext == '/') GetNextWord(styler, i+3, makoBlockType, sizeof(makoBlockType)); else @@ -1000,9 +1001,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty // handle the start Django template code else if (isDjango && scriptLanguage != eScriptPython && (ch == '{' && (chNext == '%' || chNext == '{'))) { if (chNext == '%') - strcpy(djangoBlockType, "%"); + StringCopy(djangoBlockType, "%"); else - strcpy(djangoBlockType, "{"); + StringCopy(djangoBlockType, "{"); styler.ColourTo(i - 1, StateToPrint); beforePreProc = state; if (inScriptType == eNonHtmlScript) @@ -1917,7 +1918,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HPHP_COMMENTLINE; } else if (ch == '\"') { state = SCE_HPHP_HSTRING; - strcpy(phpStringDelimiter, "\""); + StringCopy(phpStringDelimiter, "\""); } else if (styler.Match(i, "<<<")) { bool isSimpleString = false; i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString); @@ -1927,7 +1928,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } } else if (ch == '\'') { state = SCE_HPHP_SIMPLESTRING; - strcpy(phpStringDelimiter, "\'"); + StringCopy(phpStringDelimiter, "\'"); } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; } else if (IsOperator(ch)) { @@ -2047,7 +2048,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_HPHP_COMMENTLINE; } else if (ch == '\"') { state = SCE_HPHP_HSTRING; - strcpy(phpStringDelimiter, "\""); + StringCopy(phpStringDelimiter, "\""); } else if (styler.Match(i, "<<<")) { bool isSimpleString = false; i = FindPhpStringDelimiter(phpStringDelimiter, sizeof(phpStringDelimiter), i + 3, lengthDoc, styler, isSimpleString); @@ -2057,7 +2058,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } } else if (ch == '\'') { state = SCE_HPHP_SIMPLESTRING; - strcpy(phpStringDelimiter, "\'"); + StringCopy(phpStringDelimiter, "\'"); } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; } else if (IsOperator(ch)) { -- cgit v1.2.3