From 72c03af0c59383b37e07b38e295836a44aa633c4 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 2 Mar 2016 14:03:27 +0100 Subject: [PATCH] Key sequence length check added --- ZRColaCompile/dbsource.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ZRColaCompile/dbsource.cpp b/ZRColaCompile/dbsource.cpp index f7cbf71..0bad881 100644 --- a/ZRColaCompile/dbsource.cpp +++ b/ZRColaCompile/dbsource.cpp @@ -171,7 +171,6 @@ bool ZRCola::DBSource::GetKeySequence(const ATL::CComPtr& f, std::vect CComVariant v; wxVERIFY(SUCCEEDED(f->get_Value(&v))); - wxVERIFY(SUCCEEDED(v.ChangeType(VT_BSTR))); // Convert to uppercase. @@ -205,12 +204,21 @@ bool ZRCola::DBSource::GetKeySequence(const ATL::CComPtr& f, std::vect _ftprintf(stderr, wxT("%s: error ZCC0060: Syntax error in \"%.*ls\" field (\"%.*ls\"). Key sequences must be \"Ctrl+Alt+\" formatted, delimited by commas and/or space.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v)); return false; } + if (seq.size() > 0xffff) { + _ftprintf(stderr, wxT("%s: warning ZCC0061: Key sequence \"%.*ls...\" too long. Ignored.\n"), (LPCTSTR)m_filename.c_str(), std::min(n, 20), V_BSTR(&v)); + return false; + } seq.push_back(kc); // Skip delimiter(s) and whitespace. for (; i < n && V_BSTR(&v)[i] && (V_BSTR(&v)[i] == L',' || _iswspace_l(V_BSTR(&v)[i], m_locale)); i++); } + if (seq.empty()) { + _ftprintf(stderr, wxT("%s: warning ZCC0062: Empty key sequence. Ignored.\n"), (LPCTSTR)m_filename.c_str()); + return false; + } + return true; }