summaryrefslogtreecommitdiff
path: root/legacy/clucene/static-fixes.patch
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-02-12 22:08:41 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-02-12 22:08:41 -0600
commit12bf0314937b208b9c07d15972314d61ef845006 (patch)
treee3ba3ad7d158ddcec83a608b583136ae32c135f5 /legacy/clucene/static-fixes.patch
parentff814c108b7b21ef31182aa43276348c69d0c448 (diff)
downloadpackages-12bf0314937b208b9c07d15972314d61ef845006.tar.gz
packages-12bf0314937b208b9c07d15972314d61ef845006.tar.bz2
packages-12bf0314937b208b9c07d15972314d61ef845006.tar.xz
packages-12bf0314937b208b9c07d15972314d61ef845006.zip
user/clucene: Retire to legacy/
No upstream commits in years. No response to bug reports from other teams. Really weird test failures on 32-bit architectures, likely caused by interactions with signedness and 64-bit integers. Ref: #873 #880
Diffstat (limited to 'legacy/clucene/static-fixes.patch')
-rw-r--r--legacy/clucene/static-fixes.patch191
1 files changed, 191 insertions, 0 deletions
diff --git a/legacy/clucene/static-fixes.patch b/legacy/clucene/static-fixes.patch
new file mode 100644
index 000000000..8e80e81af
--- /dev/null
+++ b/legacy/clucene/static-fixes.patch
@@ -0,0 +1,191 @@
+From 6e04e9db12d0696dcd3dcc40ec61615fa5762592 Mon Sep 17 00:00:00 2001
+From: Anton Bannikov <Anton.Bannikov@Kaspersky.com>
+Date: Thu, 1 Sep 2022 16:48:07 +0300
+Subject: [PATCH] [svace] fix errors found by svace static analyzer
+
+---
+ src/core/CLucene/debug/error.cpp | 12 ++++++++++
+ src/core/CLucene/debug/error.h | 1 +
+ src/core/CLucene/index/TermInfosReader.cpp | 28 ++++++++++++----------
+ src/core/CLucene/search/MultiSearcher.cpp | 24 ++++++++++++-------
+ src/core/CLucene/util/_MD5Digester.h | 1 -
+ src/shared/CLucene/util/StringBuffer.cpp | 25 ++++++++++---------
+ 6 files changed, 57 insertions(+), 34 deletions(-)
+
+diff --git a/src/core/CLucene/debug/error.cpp b/src/core/CLucene/debug/error.cpp
+index 9b4fe3ee..e661cb86 100644
+--- a/src/core/CLucene/debug/error.cpp
++++ b/src/core/CLucene/debug/error.cpp
+@@ -46,6 +46,18 @@ CL_NS_USE(util)
+ }
+ #endif
+
++ CLuceneError& CLuceneError::operator=(const CLuceneError& other)
++ {
++ if (&other != this)
++ {
++ _awhat = STRDUP_AtoA(other._awhat);
++ _twhat = STRDUP_TtoT(other._twhat);
++ error_number = other.error_number;
++ }
++
++ return *this;
++ }
++
+ CLuceneError::CLuceneError(const CLuceneError& clone)
+ {
+ this->error_number = clone.error_number;
+diff --git a/src/core/CLucene/debug/error.h b/src/core/CLucene/debug/error.h
+index 9fe980fa..62da1e62 100644
+--- a/src/core/CLucene/debug/error.h
++++ b/src/core/CLucene/debug/error.h
+@@ -70,6 +70,7 @@ class CLUCENE_EXPORT CLuceneError
+ public:
+ CLuceneError();
+ CLuceneError(const CLuceneError& clone);
++ CLuceneError& operator=(const CLuceneError&);
+ #ifndef _ASCII
+ CLuceneError(int num, const char* str, bool ownstr);
+ #endif
+diff --git a/src/core/CLucene/index/TermInfosReader.cpp b/src/core/CLucene/index/TermInfosReader.cpp
+index 6ede797a..87e3bd83 100644
+--- a/src/core/CLucene/index/TermInfosReader.cpp
++++ b/src/core/CLucene/index/TermInfosReader.cpp
+@@ -26,7 +26,7 @@ CL_NS_DEF(index)
+
+
+ TermInfosReader::TermInfosReader(Directory* dir, const char* seg, FieldInfos* fis, const int32_t readBufferSize):
+- directory (dir),fieldInfos (fis), indexTerms(NULL), indexInfos(NULL), indexPointers(NULL), indexDivisor(1)
++ directory (dir),fieldInfos (fis), indexTerms(NULL), indexInfos(NULL), indexPointers(NULL), indexDivisor(1), indexTermsLength(0)
+ {
+ //Func - Constructor.
+ // Reads the TermInfos file (.tis) and eventually the Term Info Index file (.tii)
+@@ -172,18 +172,20 @@ CL_NS_DEF(index)
+
+ SegmentTermEnum* enumerator = getEnum();
+
+- if (
+- enumerator != NULL //an enumeration exists
+- && enumerator->term(false) != NULL // term is at or past current
+- && position >= enumerator->position
+- && position < (enumerator->position + totalIndexInterval)
+- )
+- {
+- return scanEnum(position); // can avoid seek
+- }
+-
+- //random-access: must seek
+- seekEnum(position / totalIndexInterval);
++ if (enumerator != NULL) //an enumeration exists
++ {
++ if (
++ enumerator->term(false) != NULL // term is at or past current
++ && position >= enumerator->position
++ && position < (enumerator->position + totalIndexInterval)
++ )
++ {
++ return scanEnum(position); // can avoid seek
++ }
++
++ //random-access: must seek
++ seekEnum(position / totalIndexInterval);
++ }
+
+ //Get the Term at position
+ return scanEnum(position);
+diff --git a/src/core/CLucene/search/MultiSearcher.cpp b/src/core/CLucene/search/MultiSearcher.cpp
+index 0f2a6862..1f8e99c6 100644
+--- a/src/core/CLucene/search/MultiSearcher.cpp
++++ b/src/core/CLucene/search/MultiSearcher.cpp
+@@ -207,16 +207,22 @@ CL_NS_DEF(search)
+ _CLDELETE(docs);
+ }
+
+- int32_t hqlen = hq->size();
+- fieldDocs = _CL_NEWARRAY(FieldDoc*,hqlen);
+- for (j = hqlen - 1; j >= 0; j--) // put docs in array
+- fieldDocs[j] = hq->pop();
+-
+- SortField** hqFields = hq->getFields();
+- hq->setFields(NULL); //move ownership of memory over to TopFieldDocs
+- _CLDELETE(hq);
++ TopFieldDocs* pResult = NULL;
++ if (hq)
++ {
++ int32_t hqlen = hq->size();
++ fieldDocs = _CL_NEWARRAY(FieldDoc*,hqlen);
++ for (j = hqlen - 1; j >= 0; j--) // put docs in array
++ fieldDocs[j] = hq->pop();
++
++ SortField** hqFields = hq->getFields();
++ hq->setFields(NULL); //move ownership of memory over to TopFieldDocs
++ _CLDELETE(hq);
++
++ pResult = _CLNEW TopFieldDocs (totalHits, fieldDocs, hqlen, hqFields);
++ }
+
+- return _CLNEW TopFieldDocs (totalHits, fieldDocs, hqlen, hqFields);
++ return pResult;
+ }
+
+ Query* MultiSearcher::rewrite(Query* query) {
+diff --git a/src/core/CLucene/util/_MD5Digester.h b/src/core/CLucene/util/_MD5Digester.h
+index aff913ac..e7060a24 100644
+--- a/src/core/CLucene/util/_MD5Digester.h
++++ b/src/core/CLucene/util/_MD5Digester.h
+@@ -102,7 +102,6 @@ private:
+ uint32_t m_Count[2];
+ uint8_t m_Buffer[64];
+ uint8_t m_Digest[16];
+- uint8_t m_Finalized;
+
+ };
+
+diff --git a/src/shared/CLucene/util/StringBuffer.cpp b/src/shared/CLucene/util/StringBuffer.cpp
+index 63c78bb2..57ffcba5 100644
+--- a/src/shared/CLucene/util/StringBuffer.cpp
++++ b/src/shared/CLucene/util/StringBuffer.cpp
+@@ -292,14 +292,15 @@ CL_NS_DEF(util)
+
+ //Allocate a new buffer of length bufferLength
+ TCHAR* tmp = _CL_NEWARRAY(TCHAR,bufferLength);
+- _tcsncpy(tmp, buffer, len);
+- tmp[len] = '\0';
++ if (buffer){
++ _tcsncpy(tmp, buffer, len);
++ tmp[len] = '\0';
+
+- //destroy the old buffer
+- if (buffer){
+- _CLDELETE_CARRAY(buffer);
+- }
+- //Assign the new buffer tmp to buffer
++ //destroy the old buffer
++ _CLDELETE_CARRAY(buffer);
++ }
++
++ //Assign the new buffer tmp to buffer
+ buffer = tmp;
+ }
+
+@@ -337,11 +338,13 @@ CL_NS_DEF(util)
+ //The old buffer might not have been null-terminated, so we _tcsncpy
+ //only len bytes, not len+1 bytes (the latter might read one char off the
+ //end of the old buffer), then apply the terminator to the new buffer.
+- _tcsncpy(tmp + skippingNInitialChars, buffer, len);
+- tmp[skippingNInitialChars + len] = '\0';
++ if (buffer) {
++ _tcsncpy(tmp + skippingNInitialChars, buffer, len);
++ tmp[skippingNInitialChars + len] = '\0';
+
+- //destroy the old buffer
+- _CLDELETE_LCARRAY(buffer);
++ //destroy the old buffer
++ _CLDELETE_LCARRAY(buffer);
++ }
+
+ //Assign the new buffer tmp to buffer
+ buffer = tmp;
+--
+2.37.1 (Apple Git-137.1)
+