commit:     dfb0fda447041b8658d13919e348a04f56cf1073
Author:     Jason A. Donenfeld <zx2c4 <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 16 14:36:41 2016 +0000
Commit:     Jason Donenfeld <zx2c4 <AT> gentoo <DOT> org>
CommitDate: Tue Feb 16 14:37:57 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dfb0fda4

sys-process/htop: do not crash on startup

Certain htoprc files trigger a crash at startup. Upstream's instruction
is to include this commit until a new version is released.

 sys-process/htop/files/htop-2.0.0-commlen.patch | 22 +++++++
 sys-process/htop/htop-2.0.0-r1.ebuild           | 76 +++++++++++++++++++++++++
 2 files changed, 98 insertions(+)

diff --git a/sys-process/htop/files/htop-2.0.0-commlen.patch 
b/sys-process/htop/files/htop-2.0.0-commlen.patch
new file mode 100644
index 0000000..f44e43e
--- /dev/null
+++ b/sys-process/htop/files/htop-2.0.0-commlen.patch
@@ -0,0 +1,22 @@
+From 0b70439316b4e4608c0916317ded7e6e56982de6 Mon Sep 17 00:00:00 2001
+From: Hisham <his...@gobolinux.org>
+Date: Sat, 13 Feb 2016 02:18:28 -0200
+Subject: [PATCH] Fix buffer reuse.
+
+---
+ linux/LinuxProcessList.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
+index 591210e..ec643ab 100644
+--- a/linux/LinuxProcessList.c
++++ b/linux/LinuxProcessList.c
+@@ -446,7 +446,7 @@ static void LinuxProcessList_readOomData(LinuxProcess* 
process, const char* dirn
+ }
+ 
+ static void setCommand(Process* process, const char* command, int len) {
+-   if (process->comm && process->commLen <= len) {
++   if (process->comm && process->commLen >= len) {
+       strncpy(process->comm, command, len + 1);
+    } else {
+       free(process->comm);

diff --git a/sys-process/htop/htop-2.0.0-r1.ebuild 
b/sys-process/htop/htop-2.0.0-r1.ebuild
new file mode 100644
index 0000000..f7224ea
--- /dev/null
+++ b/sys-process/htop/htop-2.0.0-r1.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+inherit autotools linux-info
+
+DESCRIPTION="interactive process viewer"
+HOMEPAGE="http://hisham.hm/htop/";
+SRC_URI="http://hisham.hm/htop/releases/${PV}/${P}.tar.gz";
+
+LICENSE="BSD GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc 
~x86 ~amd64-linux ~x86-linux"
+IUSE="kernel_FreeBSD kernel_linux openvz unicode vserver"
+
+RDEPEND="sys-libs/ncurses:0=[unicode?]"
+DEPEND="${RDEPEND}
+       virtual/pkgconfig"
+
+DOCS=( ChangeLog README )
+
+CONFIG_CHECK="~TASKSTATS ~TASK_XACCT ~TASK_IO_ACCOUNTING ~CGROUPS"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-2.0.0-tinfo.patch"
+       "${FILESDIR}/${P}-commlen.patch"
+)
+
+pkg_setup() {
+       if use kernel_FreeBSD && ! [[ -f ${ROOT}/compat/linux/proc/stat && -f 
${ROOT}/compat/linux/proc/meminfo ]]; then
+               echo
+               eerror "htop requires linprocfs mounted at /compat/linux/proc 
to build and function."
+               eerror "To mount it, type:"
+               [ -d /compat/linux/proc ] || eerror "mkdir -p 
/compat/linux/proc"
+               eerror "mount -t linprocfs none /compat/linux/proc"
+               eerror "Alternatively, place this information into /etc/fstab"
+               echo
+               die "htop needs /compat/linux/proc mounted"
+       fi
+
+       if ! has_version sys-process/lsof; then
+               ewarn "To use lsof features in htop(what processes are 
accessing"
+               ewarn "what files), you must have sys-process/lsof installed."
+       fi
+
+       linux-info_pkg_setup
+}
+
+src_prepare() {
+       rm missing || die
+
+       default
+       eautoreconf
+}
+
+src_configure() {
+       [[ $CBUILD != $CHOST ]] && export ac_cv_file__proc_{meminfo,stat}=yes 
#328971
+
+       local myeconfargs=()
+
+       use kernel_FreeBSD && myeconfargs+=( --with-proc=/compat/linux/proc )
+
+       myeconfargs+=(
+               # fails to build against recent hwloc versions
+               --disable-hwloc
+               --enable-native-affinity
+               --enable-taskstats
+               $(use_enable kernel_linux cgroup)
+               $(use_enable openvz)
+               $(use_enable unicode)
+               $(use_enable vserver)
+       )
+       econf ${myeconfargs[@]}
+}

Reply via email to