From 048ad2ff54017710af65007cb7f8ab1bd39e5d5f Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Thu, 14 Jan 2021 13:36:56 +0100 Subject: Prepare a set of patches for an upcoming 3.0.5-2 --- debian/changelog | 9 +++ debian/patches/0001-reset-cached-values.patch | 21 ++++++ .../patches/0002-fix-ncurses-field-padding.patch | 87 ++++++++++++++++++++++ debian/patches/0003-fix-hurd-build.patch | 42 +++++++++++ debian/patches/series | 3 + 5 files changed, 162 insertions(+) create mode 100644 debian/patches/0001-reset-cached-values.patch create mode 100644 debian/patches/0002-fix-ncurses-field-padding.patch create mode 100644 debian/patches/0003-fix-hurd-build.patch create mode 100644 debian/patches/series diff --git a/debian/changelog b/debian/changelog index a5d3853..45e9602 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +htop (3.0.5-2) UNRELEASED; urgency=medium + + * Backport patches to fix: + - Possible segfault in colored ("rich") string handling + - Issue in field background coloring + - Build for GNU/hurd (missing PATH_MAX in their limits.h) + + -- Daniel Lange Thu, 14 Jan 2021 13:34:00 +0100 + htop (3.0.5-1) unstable; urgency=medium * New upstream release 3.0.5 diff --git a/debian/patches/0001-reset-cached-values.patch b/debian/patches/0001-reset-cached-values.patch new file mode 100644 index 0000000..46ff165 --- /dev/null +++ b/debian/patches/0001-reset-cached-values.patch @@ -0,0 +1,21 @@ +Backport of https://github.com/htop-dev/htop/pull/473 + +--- a/linux/LinuxProcessList.c 2021-01-11 20:43:28.186510057 +0100 ++++ b/linux/LinuxProcessList.c 2021-01-14 13:48:23.452808449 +0100 +@@ -1454,10 +1454,16 @@ + if (proc->state == 'Z' && (proc->basenameOffset == 0)) { + proc->basenameOffset = -1; + setCommand(proc, command, commLen); ++ lp->procCmdlineBasenameOffset = 0; ++ lp->procCmdlineBasenameEnd = 0; ++ lp->mergedCommand.commChanged = true; + } else if (Process_isThread(proc)) { + if (settings->showThreadNames || Process_isKernelThread(proc) || (proc->state == 'Z' && proc->basenameOffset == 0)) { + proc->basenameOffset = -1; + setCommand(proc, command, commLen); ++ lp->procCmdlineBasenameOffset = 0; ++ lp->procCmdlineBasenameEnd = 0; ++ lp->mergedCommand.commChanged = true; + } else if (settings->showThreadNames) { + if (! LinuxProcessList_readCmdlineFile(proc, procFd)) { + goto errorReadingProcess; diff --git a/debian/patches/0002-fix-ncurses-field-padding.patch b/debian/patches/0002-fix-ncurses-field-padding.patch new file mode 100644 index 0000000..a40b89f --- /dev/null +++ b/debian/patches/0002-fix-ncurses-field-padding.patch @@ -0,0 +1,87 @@ +Backport of upstream 5fde0e012762b07e4955306b743afcf43fe237c6 + +Allows to set attributes when padding process fields in non-wide ncurses mode. + +--- a/Meter.c ++++ b/Meter.c +@@ -202,7 +202,7 @@ + // The text in the bar is right aligned; + // Pad with maximal spaces and then calculate needed starting position offset + RichString_begin(bar); +- RichString_appendChr(&bar, ' ', w); ++ RichString_appendChr(&bar, 0, ' ', w); + RichString_appendWide(&bar, 0, buffer); + int startPos = RichString_sizeVal(bar) - w; + if (startPos > w) { +--- a/Process.c ++++ b/Process.c +@@ -246,7 +246,7 @@ + + void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width) { + int c = RichString_appendnWide(str, attr, content, MINIMUM(width, strlen(content))); +- RichString_appendChr(str, ' ', width + 1 - c); ++ RichString_appendChr(str, attr, ' ', width + 1 - c); + } + + void Process_writeField(const Process* this, RichString* str, ProcessField field) { +--- a/RichString.c ++++ b/RichString.c +@@ -80,6 +80,15 @@ + } + } + ++void RichString_appendChr(RichString* this, int attrs, char c, int count) { ++ int from = this->chlen; ++ int newLen = from + count; ++ RichString_setLen(this, newLen); ++ for (int i = from; i < newLen; i++) { ++ this->chptr[i] = (CharType) { .attr = attrs, .chars = { c, 0 } }; ++ } ++} ++ + int RichString_findChar(RichString* this, char c, int start) { + wchar_t wc = btowc(c); + cchar_t* ch = this->chptr + start; +@@ -115,6 +124,15 @@ + } + } + ++void RichString_appendChr(RichString* this, int attrs, char c, int count) { ++ int from = this->chlen; ++ int newLen = from + count; ++ RichString_setLen(this, newLen); ++ for (int i = from; i < newLen; i++) { ++ this->chptr[i] = c | attrs; ++ } ++} ++ + int RichString_findChar(RichString* this, char c, int start) { + chtype* ch = this->chptr + start; + for (int i = start; i < this->chlen; i++) { +@@ -134,15 +152,6 @@ + this->chptr = this->chstr; + } + +-void RichString_appendChr(RichString* this, char c, int count) { +- int from = this->chlen; +- int newLen = from + count; +- RichString_setLen(this, newLen); +- for (int i = from; i < newLen; i++) { +- RichString_setChar(this, i, c); +- } +-} +- + void RichString_setAttr(RichString* this, int attrs) { + RichString_setAttrn(this, attrs, 0, this->chlen); + } +--- a/RichString.h ++++ b/RichString.h +@@ -50,7 +50,7 @@ + + void RichString_setAttr(RichString* this, int attrs); + +-void RichString_appendChr(RichString* this, char c, int count); ++void RichString_appendChr(RichString* this, int attrs, char c, int count); + + int RichString_appendWide(RichString* this, int attrs, const char* data); + diff --git a/debian/patches/0003-fix-hurd-build.patch b/debian/patches/0003-fix-hurd-build.patch new file mode 100644 index 0000000..8e77927 --- /dev/null +++ b/debian/patches/0003-fix-hurd-build.patch @@ -0,0 +1,42 @@ +commit ecfe8794dc705d5ceaf8202c7cab73f3457d4d48 (HEAD -> fix-hurd-build, gh-fit/fix-hurd-build) +Author: Daniel Lange +Date: Thu Jan 14 13:27:47 2021 +0100 + + Define PATH_MAX for GNU/hurd + + Otherwise fails with + "> linux/LinuxProcessList.c:889:20: error: ‘PATH_MAX’ undeclared (first use in this function)" + +--- a/linux/Platform.c ++++ b/linux/Platform.c +@@ -14,7 +14,6 @@ + #include + #include + #include +-#include + #include + #include + #include +--- a/linux/Platform.h ++++ b/linux/Platform.h +@@ -7,6 +7,7 @@ + in the source distribution for its full text. + */ + ++#include + #include + #include + +@@ -18,6 +19,12 @@ + #include "ProcessLocksScreen.h" + #include "SignalsPanel.h" + ++/* GNU/Hurd does not have PATH_MAX in limits.h */ ++#ifndef PATH_MAX ++ #define PATH_MAX 4096 ++#endif ++ ++ + extern const ProcessField Platform_defaultFields[]; + + extern const SignalItem Platform_signals[]; diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4bde4ca --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,3 @@ +0001-reset-cached-values.patch +0002-fix-ncurses-field-padding.patch +0003-fix-hurd-build.patch -- cgit v1.2.3