From 45963d9b136fd7ca63a11c364b4f1eb94f95f554 Mon Sep 17 00:00:00 2001
From: Stefan Hofmann <stefan.hofmann@t-online.de>
Date: Tue, 13 May 2025 13:00:09 +0200
Subject: [PATCH] Fixes and annotations

---
 Makefile              | 2 +-
 README                | 1 -
 blacklist.c           | 4 ++++
 epgsearchcfg.h        | 2 +-
 epgsearchext.c        | 3 ++-
 epgsearchext.h        | 5 +++++
 md5.c                 | 2 +-
 menu_blacklists.c     | 2 +-
 menu_search.c         | 2 +-
 menu_searchedit.c     | 2 +-
 menu_searchtemplate.c | 2 +-
 menu_whatson.c        | 3 +--
 services.c            | 2 +-
 13 files changed, 20 insertions(+), 12 deletions(-)
 delete mode 120000 README

diff --git a/Makefile b/Makefile
index 6a4f4f9..5d81757 100644
--- a/Makefile
+++ b/Makefile
@@ -88,7 +88,7 @@ export CXXFLAGS = $(call PKGCFG,cxxflags)
 ### configuring modules
 ifeq ($(AUTOCONFIG),1)
 	ifeq (exists, $(shell $(PKG_CONFIG) libpcre2-posix && echo exists))
-    REGEXLIB = pcre2
+		REGEXLIB = pcre2
 	else ifeq (exists, $(shell $(PKG_CONFIG) libpcre && echo exists))
 		REGEXLIB = pcre
 	else ifeq (exists, $(shell $(PKG_CONFIG) tre && echo exists))
diff --git a/README b/README
deleted file mode 120000
index b16bb82..0000000
--- a/README
+++ /dev/null
@@ -1 +0,0 @@
-./doc/en/epgsearch.1.txt
\ No newline at end of file
diff --git a/blacklist.c b/blacklist.c
index 53f0cca..b64f0c1 100644
--- a/blacklist.c
+++ b/blacklist.c
@@ -102,7 +102,11 @@ cBlacklist::~cBlacklist(void)
 cBlacklist& cBlacklist::operator= (const cBlacklist &Blacklist)
 {
     char**   catvaluesTemp = this->catvalues;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+    // TODO: this shallow copy does not duplicate all strings -> can this cause trouble?
     memcpy(this, &Blacklist, sizeof(*this));
+#pragma GCC diagnostic pop
     this->catvalues = catvaluesTemp;
 
     cSearchExtCat *SearchExtCat = SearchExtCats.First();
diff --git a/epgsearchcfg.h b/epgsearchcfg.h
index e871b2e..6b350e3 100644
--- a/epgsearchcfg.h
+++ b/epgsearchcfg.h
@@ -72,7 +72,7 @@ public:
     }
 
     void SetDescription(const char* szD) {
-        if (szD)  strncpy(description, szD, sizeof(description));
+        if (szD)  strn0cpy(description, szD, sizeof(description));
     }
     void SetTime(int iT) {
         itime = iT;
diff --git a/epgsearchext.c b/epgsearchext.c
index b89a4e7..f633be1 100644
--- a/epgsearchext.c
+++ b/epgsearchext.c
@@ -235,6 +235,7 @@ void cSearchExt::CopyFromTemplate(const cSearchExt* templ, bool ignoreChannelSet
     useAsSearchTimerTil = templ->useAsSearchTimerTil;
     ignoreMissingEPGCats = templ->ignoreMissingEPGCats;
     unmuteSoundOnSwitch = templ->unmuteSoundOnSwitch;
+    skipRunningEvents = templ->skipRunningEvents;
 }
 
 bool cSearchExt::operator< (const cListObject &ListObject)
@@ -384,7 +385,7 @@ const char *cSearchExt::ToText()
              ignoreMissingEPGCats,
              unmuteSoundOnSwitch,
              compareSummaryMatchInPercent,
-             contentsFilter.c_str(),
+             tmp_contentsFilter,
              compareDate);
 
     if (tmp_search) free(tmp_search);
diff --git a/epgsearchext.h b/epgsearchext.h
index 43e559d..8200978 100644
--- a/epgsearchext.h
+++ b/epgsearchext.h
@@ -111,6 +111,11 @@ class cSearchExt : public cListObject
     friend class cMenuEditTemplate;
 public:
     int      ID;
+    // note that all strings have a discrepancy in the characters that
+    // can be entered and the characters that can be stored, because every
+    // entered '|' character will be replaced by a multi-character string
+    // for the configuration file and thus potentially discards characters
+    // at the end the fixed-size buffer before storing
     char     search[MaxFileName];
     int      options;
     int      useTime;
diff --git a/md5.c b/md5.c
index 1557ff4..0d4d6a5 100644
--- a/md5.c
+++ b/md5.c
@@ -99,7 +99,7 @@ char* PrintMD5(uchar md5Digest[16])
 
     for (nCount = 0; nCount < 16; nCount++) {
         sprintf(chEach, "%02x", md5Digest[nCount]);
-        strncat(chBuffer, chEach, sizeof(chEach));
+        strncat(chBuffer, chEach, 10);
     }
 
     return strdup(chBuffer);
diff --git a/menu_blacklists.c b/menu_blacklists.c
index b0567a9..435b85d 100644
--- a/menu_blacklists.c
+++ b/menu_blacklists.c
@@ -59,7 +59,7 @@ void cMenuBlacklistsItem::Set(void)
         line << setiosflags(ios::left) << "G";
     line << "\t";
 
-    if (blacklist->search && strlen(blacklist->search) > 0)
+    if (strlen(blacklist->search) > 0)
         line << setiosflags(ios::left) << string(blacklist->search);
     else
         line << setiosflags(ios::left) << "*";
diff --git a/menu_search.c b/menu_search.c
index f5bfe6f..5f2a4ea 100644
--- a/menu_search.c
+++ b/menu_search.c
@@ -65,7 +65,7 @@ void cMenuSearchExtItem::Set(void)
     }
 
     line << "\t";
-    if (searchExt->search && strlen(searchExt->search) > 0)
+    if (strlen(searchExt->search) > 0)
         line << setiosflags(ios::left) << string(searchExt->search);
     else
         line << setiosflags(ios::left) << "*";
diff --git a/menu_searchedit.c b/menu_searchedit.c
index b70c5bd..2e54782 100644
--- a/menu_searchedit.c
+++ b/menu_searchedit.c
@@ -337,7 +337,7 @@ void cMenuEditSearchExt::Set()
                 if (data.allowedRepeats > 0)
                     Add(new cMenuEditIntItem(IndentMenuItem(tr("Only repeats within ... days"), 2), &data.repeatsWithinDays, 0, 999));
                 Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare title"), 2), &data.compareTitle, trVDR("no"), trVDR("yes")));
-                Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare subtitle"), 3), &data.compareSubtitle, 3, CompareSubtitleModes));
+                Add(new cMenuEditStraItem(IndentMenuItem(tr("Compare subtitle"), 2), &data.compareSubtitle, 3, CompareSubtitleModes));
                 Add(new cMenuEditBoolItem(IndentMenuItem(tr("Compare summary"), 2), &data.compareSummary, trVDR("no"), trVDR("yes")));
                 if (data.compareSummary)
                     Add(new cMenuEditIntItem(IndentMenuItem(tr("Min. match in %"), 3), &data.compareSummaryMatchInPercent, 1, 100));
diff --git a/menu_searchtemplate.c b/menu_searchtemplate.c
index 3a837b6..f361f29 100644
--- a/menu_searchtemplate.c
+++ b/menu_searchtemplate.c
@@ -66,7 +66,7 @@ void cMenuSearchTemplateItem::Set(void)
     }
 
     line << "\t";
-    if (searchExt->search && strlen(searchExt->search) > 0)
+    if (strlen(searchExt->search) > 0)
         line << setiosflags(ios::left) << string(searchExt->search);
     else
         line << setiosflags(ios::left) << "*";
diff --git a/menu_whatson.c b/menu_whatson.c
index 2d18116..f7148ee 100644
--- a/menu_whatson.c
+++ b/menu_whatson.c
@@ -136,8 +136,7 @@ bool cMenuMyScheduleItem::Update(const cTimers* Timers, bool Force)
 #endif
                     }
                 } else {
-                    strncpy(szProgressPart, *event->GetTimeString(), 12);
-                    szProgressPart[11] = 0;
+                    strn0cpy(szProgressPart, *event->GetTimeString(), 12);
                     memcpy(szProgressPartT2S, szProgressPart, 12);
                 }
             }
diff --git a/services.c b/services.c
index 31749f2..f540e74 100644
--- a/services.c
+++ b/services.c
@@ -280,7 +280,7 @@ std::list<std::string> cEpgsearchServiceHandler::TimerConflictList(bool relOnly)
             for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it) {
                 if (relOnly && (*it)->ignore) continue;
                 std::ostringstream timerpart;
-                int recPart = (*it)->recDuration * 100 / ((*it)->stop - (*it)->start);
+                int recPart = (*it)->stop - (*it)->start > 0 ? (*it)->recDuration * 100 / ((*it)->stop - (*it)->start) : 0;
                 timerpart << (*it)->timer->Id() << "|" << recPart << "|";
                 std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator itcc;
                 if ((*it)->concurrentTimers) {
-- 
2.49.0.windows.1

