From 4421161848057ad15d37c240b59b0eac867b6aa3 Mon Sep 17 00:00:00 2001 From: Don HO Date: Fri, 18 Jan 2019 23:09:00 +0100 Subject: [PATCH] [EU-FOSSA] Fix stack overflow issue while affecting "ext" field on stylers.xml --- PowerEditor/src/MISC/Common/Common.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 99c79cdb..adf5458f 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -326,11 +326,14 @@ bool isInList(const TCHAR *token, const TCHAR *list) if ((!token) || (!list)) return false; - TCHAR word[64]; + const size_t wordLen = 64; + size_t listLen = lstrlen(list); + + TCHAR word[wordLen]; size_t i = 0; size_t j = 0; - for (size_t len = lstrlen(list); i <= len; ++i) + for (; i <= listLen; ++i) { if ((list[i] == ' ')||(list[i] == '\0')) { @@ -347,6 +350,9 @@ bool isInList(const TCHAR *token, const TCHAR *list) { word[j] = list[i]; ++j; + + if (j >= wordLen) + return false; } } return false;