sync patchs
This commit is contained in:
parent
069fb02a2d
commit
b19dc4842d
@ -1,60 +1,60 @@
|
||||
From bb96fc42956c9ed926a1b958ab715f8b4a663dec Mon Sep 17 00:00:00 2001
|
||||
From: Craig Small <csmall@dropbear.xyz>
|
||||
Date: Sun, 5 Jan 2020 15:05:55 +1100
|
||||
Subject: [PATCH] pgrep: check sanity of SC_ARG_MAX
|
||||
|
||||
A kernel change means we cannot trust what sysconf(SC_ARG_MAX)
|
||||
returns. We clamp it so its more than 4096 and less than 128*1024
|
||||
which is what findutils does.
|
||||
|
||||
References:
|
||||
procps-ng/procps#152
|
||||
https://git.savannah.gnu.org/cgit/findutils.git/tree/lib/buildcmd.c#n535
|
||||
https://lwn.net/Articles/727862/
|
||||
---
|
||||
pgrep.c | 22 +++++++++++++++++++++-
|
||||
1 file changed, 21 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pgrep.c b/pgrep.c
|
||||
index 01563db..bde7448 100644
|
||||
--- a/pgrep.c
|
||||
+++ b/pgrep.c
|
||||
@@ -485,6 +485,26 @@ static regex_t * do_regcomp (void)
|
||||
return preg;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * SC_ARG_MAX used to return the maximum size a command line can be
|
||||
+ * however changes to the kernel mean this can be bigger than we can
|
||||
+ * alloc. Clamp it to 128kB like xargs and friends do
|
||||
+ * Should also not be smaller than POSIX_ARG_MAX which is 4096
|
||||
+ */
|
||||
+static size_t get_arg_max(void)
|
||||
+{
|
||||
+#define MIN_ARG_SIZE 4096u
|
||||
+#define MAX_ARG_SIZE (128u * 1024u)
|
||||
+
|
||||
+ size_t val = sysconf(_SC_ARG_MAX);
|
||||
+
|
||||
+ if (val < MIN_ARG_SIZE)
|
||||
+ val = MIN_ARG_SIZE;
|
||||
+ if (val > MAX_ARG_SIZE)
|
||||
+ val = MAX_ARG_SIZE;
|
||||
+
|
||||
+ return val;
|
||||
+}
|
||||
static struct el * select_procs (int *num)
|
||||
{
|
||||
PROCTAB *ptp;
|
||||
@@ -497,7 +517,7 @@ static struct el * select_procs (int *num)
|
||||
regex_t *preg;
|
||||
pid_t myself = getpid();
|
||||
struct el *list = NULL;
|
||||
- long cmdlen = sysconf(_SC_ARG_MAX) * sizeof(char);
|
||||
+ long cmdlen = get_arg_max() * sizeof(char);
|
||||
char *cmdline = xmalloc(cmdlen);
|
||||
char *cmdsearch = xmalloc(cmdlen);
|
||||
char *cmdoutput = xmalloc(cmdlen);
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
From bb96fc42956c9ed926a1b958ab715f8b4a663dec Mon Sep 17 00:00:00 2001
|
||||
From: Craig Small <csmall@dropbear.xyz>
|
||||
Date: Sun, 5 Jan 2020 15:05:55 +1100
|
||||
Subject: [PATCH] pgrep: check sanity of SC_ARG_MAX
|
||||
|
||||
A kernel change means we cannot trust what sysconf(SC_ARG_MAX)
|
||||
returns. We clamp it so its more than 4096 and less than 128*1024
|
||||
which is what findutils does.
|
||||
|
||||
References:
|
||||
procps-ng/procps#152
|
||||
https://git.savannah.gnu.org/cgit/findutils.git/tree/lib/buildcmd.c#n535
|
||||
https://lwn.net/Articles/727862/
|
||||
---
|
||||
pgrep.c | 22 +++++++++++++++++++++-
|
||||
1 file changed, 21 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/pgrep.c b/pgrep.c
|
||||
index 01563db..bde7448 100644
|
||||
--- a/pgrep.c
|
||||
+++ b/pgrep.c
|
||||
@@ -485,6 +485,26 @@ static regex_t * do_regcomp (void)
|
||||
return preg;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * SC_ARG_MAX used to return the maximum size a command line can be
|
||||
+ * however changes to the kernel mean this can be bigger than we can
|
||||
+ * alloc. Clamp it to 128kB like xargs and friends do
|
||||
+ * Should also not be smaller than POSIX_ARG_MAX which is 4096
|
||||
+ */
|
||||
+static size_t get_arg_max(void)
|
||||
+{
|
||||
+#define MIN_ARG_SIZE 4096u
|
||||
+#define MAX_ARG_SIZE (128u * 1024u)
|
||||
+
|
||||
+ size_t val = sysconf(_SC_ARG_MAX);
|
||||
+
|
||||
+ if (val < MIN_ARG_SIZE)
|
||||
+ val = MIN_ARG_SIZE;
|
||||
+ if (val > MAX_ARG_SIZE)
|
||||
+ val = MAX_ARG_SIZE;
|
||||
+
|
||||
+ return val;
|
||||
+}
|
||||
static struct el * select_procs (int *num)
|
||||
{
|
||||
PROCTAB *ptp;
|
||||
@@ -497,7 +517,7 @@ static struct el * select_procs (int *num)
|
||||
regex_t *preg;
|
||||
pid_t myself = getpid();
|
||||
struct el *list = NULL;
|
||||
- long cmdlen = sysconf(_SC_ARG_MAX) * sizeof(char);
|
||||
+ long cmdlen = get_arg_max() * sizeof(char);
|
||||
char *cmdline = xmalloc(cmdlen);
|
||||
char *cmdsearch = xmalloc(cmdlen);
|
||||
char *cmdoutput = xmalloc(cmdlen);
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
From 00028aa23732598aecad6f1c146f3f9751372958 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed, 1 Jan 2020 00:00:00 -0500
|
||||
Subject: [PATCH] top: whack insidious bug surrounding auto-sized fields
|
||||
|
||||
This commit duplicates a change to that newlib branch.
|
||||
However, it should be noted that such a change was not
|
||||
really necessary under this master branch since proc_t
|
||||
data remains valid much longer. It is being duplicated
|
||||
here as documentation only. Below is the original msg.
|
||||
|
||||
------------------------------------------------------
|
||||
This patch will eliminate a bug which is unique to our
|
||||
newlib branch. It's extremely rare and only happens if
|
||||
a search ('L'/'&') is initiated during the period when
|
||||
fields are currently being auto-sized (AUTOX_MODE on).
|
||||
|
||||
This bug surfaces as either all zero results for tasks
|
||||
displayed or a segmentation fault, depending upon what
|
||||
fields were activated. It is caused by the timing of a
|
||||
call to the <pids> 'reset' function. When called after
|
||||
a task refresh, but before do_key(), this bug appears.
|
||||
|
||||
So this patch just ensures that 'reset' will be called
|
||||
after do_key() & before the tasks have been refreshed.
|
||||
------------------------------------------------------
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 11 ++++++-----
|
||||
top/top.h | 2 +-
|
||||
2 files changed, 7 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 1aa5a8c..09b8ef9 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -2320,7 +2320,8 @@ static inline void widths_resize (void) {
|
||||
Autox_found = 1;
|
||||
}
|
||||
}
|
||||
- if (Autox_found) calibrate_fields();
|
||||
+ // trigger a call to calibrate_fields (via zap_fieldstab)
|
||||
+ if (Autox_found) Frames_signal = BREAK_autox;
|
||||
} // end: widths_resize
|
||||
|
||||
|
||||
@@ -6407,6 +6408,10 @@ static void frame_make (void) {
|
||||
WIN_t *w = Curwin; // avoid gcc bloat with a local copy
|
||||
int i, scrlins;
|
||||
|
||||
+ // check auto-sized width increases from the last iteration...
|
||||
+ if (AUTOX_MODE && Autox_found)
|
||||
+ widths_resize();
|
||||
+
|
||||
// deal with potential signal(s) since the last time around...
|
||||
if (Frames_signal)
|
||||
zap_fieldstab();
|
||||
@@ -6459,10 +6464,6 @@ static void frame_make (void) {
|
||||
/* we'll deem any terminal not supporting tgoto as dumb and disable
|
||||
the normal non-interactive output optimization... */
|
||||
if (!Cap_can_goto) PSU_CLREOS(0);
|
||||
-
|
||||
- /* lastly, check auto-sized width needs for the next iteration */
|
||||
- if (AUTOX_MODE && Autox_found)
|
||||
- widths_resize();
|
||||
} // end: frame_make
|
||||
|
||||
|
||||
diff --git a/top/top.h b/top/top.h
|
||||
index 2a578b8..432a4f4 100644
|
||||
--- a/top/top.h
|
||||
+++ b/top/top.h
|
||||
@@ -224,7 +224,7 @@ enum scale_enum {
|
||||
|
||||
/* Used to manipulate (and document) the Frames_signal states */
|
||||
enum resize_states {
|
||||
- BREAK_off = 0, BREAK_kbd, BREAK_sig
|
||||
+ BREAK_off = 0, BREAK_kbd, BREAK_sig, BREAK_autox
|
||||
};
|
||||
|
||||
/* This typedef just ensures consistent 'process flags' handling */
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
From 9e4c2cca392399d7e1cf167816913581631b842c Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Fri, 3 Jan 2020 00:00:00 -0600
|
||||
Subject: [PATCH] top: at abnormal end allow core dumps (fix qualys bug)
|
||||
|
||||
A Qualys audit patch, represented in the commit below,
|
||||
added the _exit() call to our abnormal signal handler.
|
||||
Unfortunately, that disabled the associated core dump.
|
||||
|
||||
This patch restores expected behavior of those signals
|
||||
whose default produces a core dump file + termination.
|
||||
|
||||
Reference(s):
|
||||
commit 0847390b8335c1747a3ea0944123b2f594251bc0
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 8 ++++++--
|
||||
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 09b8ef9..8e8c7d9 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -579,18 +579,22 @@ static void error_exit (const char *str) {
|
||||
|
||||
/*
|
||||
* Catches all remaining signals not otherwise handled */
|
||||
+static void sig_abexit (int sig) NORETURN;
|
||||
static void sig_abexit (int sig) {
|
||||
sigset_t ss;
|
||||
|
||||
-// POSIX.1-2004 async-signal-safe: sigfillset, sigprocmask, signal, raise
|
||||
+// POSIX.1-2004 async-signal-safe: sigfillset, sigprocmask, signal, sigemptyset, sigaddset, raise
|
||||
sigfillset(&ss);
|
||||
sigprocmask(SIG_BLOCK, &ss, NULL);
|
||||
at_eoj(); // restore tty in preparation for exit
|
||||
fprintf(stderr, N_fmt(EXIT_signals_fmt)
|
||||
, sig, signal_number_to_name(sig), Myname);
|
||||
signal(sig, SIG_DFL); // allow core dumps, if applicable
|
||||
+ sigemptyset(&ss);
|
||||
+ sigaddset(&ss, sig);
|
||||
+ sigprocmask(SIG_UNBLOCK, &ss, NULL);
|
||||
raise(sig); // ( plus set proper return code )
|
||||
- _exit(sig | 0x80); // if default sig action is ignore
|
||||
+ _exit(EXIT_FAILURE); // if default sig action is ignore
|
||||
} // end: sig_abexit
|
||||
|
||||
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
From 7db65421d0a964f898312ce29ae044019e40958a Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Sat, 4 Jan 2020 00:00:00 -0600
|
||||
Subject: [PATCH] ps: for abnormal end allow core dumps (fix qualys bug)
|
||||
|
||||
A Qualys audit patch, represented in the commit below,
|
||||
added the _exit() call to our abnormal signal handler.
|
||||
Unfortunately, that disabled the associated core dump.
|
||||
|
||||
This patch restores expected behavior of those signals
|
||||
whose default produces a core dump file + termination.
|
||||
|
||||
Reference(s):
|
||||
commit 2e4a59422104ed7fa5502874f9076b8118edd6a8
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
ps/display.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/ps/display.c b/ps/display.c
|
||||
index 28e1a6e..95a55c3 100644
|
||||
--- a/ps/display.c
|
||||
+++ b/ps/display.c
|
||||
@@ -48,6 +48,10 @@ char *myname;
|
||||
|
||||
/* just reports a crash */
|
||||
static void signal_handler(int signo){
|
||||
+ sigset_t ss;
|
||||
+
|
||||
+ sigfillset(&ss);
|
||||
+ sigprocmask(SIG_BLOCK, &ss, NULL);
|
||||
if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
|
||||
/* fprintf() is not reentrant, but we _exit() anyway */
|
||||
fprintf(stderr,
|
||||
@@ -65,6 +69,9 @@ static void signal_handler(int signo){
|
||||
default:
|
||||
error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
|
||||
signal(signo, SIG_DFL); /* allow core file creation */
|
||||
+ sigemptyset(&ss);
|
||||
+ sigaddset(&ss, signo);
|
||||
+ sigprocmask(SIG_UNBLOCK, &ss, NULL);
|
||||
kill(getpid(), signo);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From ed34b1228ed08fbfdbf6f1a61ca7ca62448ccd86 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed, 22 Jan 2020 00:00:00 -0600
|
||||
Subject: [PATCH] top: restore one line of code to sig_endpgm() function
|
||||
|
||||
When that potential abend at program end was addressed
|
||||
in the patch shown below, one line of code was removed
|
||||
in error. That line served to suppress some end-of-job
|
||||
reports should ATEOJ_RPTSTD or ATEOJ_RPTHSH be active.
|
||||
|
||||
So, this patch restores that previously deleted logic.
|
||||
|
||||
Reference(s):
|
||||
. potential SEGV fix, master branch
|
||||
commit d37f85c269fbb6e905802ffdbce0ba4173ba21a9
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 8e8c7d9..63ec5fe 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -604,6 +604,7 @@ static void sig_abexit (int sig) {
|
||||
* SIGUSR1 and SIGUSR2 */
|
||||
static void sig_endpgm (int dont_care_sig) NORETURN;
|
||||
static void sig_endpgm (int dont_care_sig) {
|
||||
+ Frames_signal = BREAK_sig;
|
||||
bye_bye(NULL);
|
||||
(void)dont_care_sig;
|
||||
} // end: sig_endpgm
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
From 5cd29e5093efa3c6ee9c5310b64347f1d54b707d Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Sat, 15 Feb 2020 00:00:00 -0600
|
||||
Subject: [PATCH] top: restore configuration file backward compatibility
|
||||
|
||||
The Debian bug referenced below has nothing to do with
|
||||
locales. In fact, top was made locale independent back
|
||||
in release 3.3.13 (April, 2018). However, that bug did
|
||||
reveal some misplaced logic which this patch corrects.
|
||||
|
||||
Prompted by the Qualys audit, all rcfile field strings
|
||||
were checked for potential duplicates which could only
|
||||
have resulted from some user's manual/malicious edits.
|
||||
|
||||
Unfortunately, that code was executed before top had a
|
||||
chance to enforce the proper/maximum string length (in
|
||||
the event an extremely old rcfile had just been read).
|
||||
This created some potential string overrun references.
|
||||
|
||||
In top's original 3.3.15 implementation, the potential
|
||||
overrun extended for 15 characters. That is the number
|
||||
of field characters added with 3.3.9 (December, 2013).
|
||||
But, since strchr() was used, no error exit was taken.
|
||||
|
||||
In the revised 3.3.16 implementation, the strchr() was
|
||||
replaced with '&w->rc.fieldscur[n]'. This held overrun
|
||||
to a single position while producing an error message.
|
||||
|
||||
So, this commit just moves that logic to a point where
|
||||
fieldscur is guaranteed to be longer than EU_MAXPFLGS.
|
||||
|
||||
Reference(s):
|
||||
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951335
|
||||
. revised 3.3.16 validation logic
|
||||
commit 291d98ee5036567f93d21bc11142b0a7e2ee70ae
|
||||
. original 3.3.15 validation logic
|
||||
commit fdb58974e24c025a1f866f324c62f1d8f96234f8
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
|
||||
This patch has been modified to fit euler os
|
||||
Signed-off-by: chenmingmin <chenmingmin@huawei.com>
|
||||
---
|
||||
top/top.c | 10 +++++-----
|
||||
1 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 63ec5fe..b4fe21e 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -3939,11 +3939,6 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
// too bad fscanf is not as flexible with his format string as snprintf
|
||||
#error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
|
||||
#endif
|
||||
- // ensure there's been no manual alteration of fieldscur
|
||||
- for (n = 0 ; n < EU_MAXPFLGS; n++) {
|
||||
- if (&w->rc.fieldscur[n] != strrchr(w->rc.fieldscur, w->rc.fieldscur[n]))
|
||||
- return p;
|
||||
- }
|
||||
// be tolerant of missing release 3.3.10 graph modes additions
|
||||
if (3 > fscanf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d, graph_cpus=%d, graph_mems=%d\n"
|
||||
, &w->rc.winflags, &w->rc.sortindx, &w->rc.maxtasks, &w->rc.graph_cpus, &w->rc.graph_mems))
|
||||
@@ -3989,6 +3984,11 @@ static const char *configs_file (FILE *fp, const char *name, float *delay) {
|
||||
return p;
|
||||
break;
|
||||
}
|
||||
+ // ensure there's been no manual alteration of fieldscur
|
||||
+ for (n = 0 ; n < EU_MAXPFLGS; n++) {
|
||||
+ if (&w->rc.fieldscur[n] != strrchr(w->rc.fieldscur, w->rc.fieldscur[n]))
|
||||
+ return p;
|
||||
+ }
|
||||
#ifndef USE_X_COLHDR
|
||||
OFFw(w, NOHIFND_xxx | NOHISEL_xxx);
|
||||
#endif
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
From b52a26740445904c01233166271817743f2e4b40 Mon Sep 17 00:00:00 2001
|
||||
From: Dylan Swiggett <swiggett@google.com>
|
||||
Date: Tue, 29 Nov 2016 22:34:37 +0000
|
||||
Subject: [PATCH] Fixes small bug in struct proc_t documentation.
|
||||
|
||||
From http://man7.org/linux/man-pages/man5/proc.5.html:
|
||||
|
||||
(22) starttime %llu
|
||||
The time the process started after system boot. In
|
||||
kernels before Linux 2.6, this value was expressed
|
||||
in jiffies. Since Linux 2.6, the value is expressed
|
||||
in clock ticks (divide by sysconf(_SC_CLK_TCK)).
|
||||
---
|
||||
proc/readproc.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/proc/readproc.h b/proc/readproc.h
|
||||
index a3fdb51..7905ea9 100644
|
||||
--- a/proc/readproc.h
|
||||
+++ b/proc/readproc.h
|
||||
@@ -74,7 +74,7 @@ typedef struct proc_t {
|
||||
// and so on...
|
||||
cutime, // stat cumulative utime of process and reaped children
|
||||
cstime, // stat cumulative stime of process and reaped children
|
||||
- start_time; // stat start time of process -- seconds since 1-1-70
|
||||
+ start_time; // stat start time of process -- seconds since system boot
|
||||
#ifdef SIGNAL_STRING
|
||||
char
|
||||
// Linux 2.1.7x and up have 64 signals. Allow 64, plus '\0' and padding.
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From 64a17dfe35d4f0fdd8658156bf920578b32a497f Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed, 7 Oct 2020 17:06:36 +0800
|
||||
Subject: [PATCH 32/34] misc: eliminate a couple of miscellaneous gcc warnings
|
||||
|
||||
This commit just addresses those warnings shown below.
|
||||
|
||||
Reference(s):
|
||||
proc/sysinfo.c: In function `getrunners':
|
||||
proc/sysinfo.c:491:26: warning: `%s' directive writing up to 255 bytes into a region of size 26 [-Wformat-overflow=]
|
||||
491 | sprintf(tbuf, "/proc/%s/stat", ent->d_name);
|
||||
| ^~
|
||||
https://gitlab.com/procps-ng/procps/-/commit/e3196502784b11c70d6e3c33159403d2f7c118e1
|
||||
|
||||
This patch has been modified to fit euler os
|
||||
Signed-off-by: chenmingmin <chenmingmin@huawei.com>
|
||||
---
|
||||
proc/sysinfo.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/proc/sysinfo.c b/proc/sysinfo.c
|
||||
index 4b2090b..5daa70b 100644
|
||||
--- a/proc/sysinfo.c
|
||||
+++ b/proc/sysinfo.c
|
||||
@@ -488,7 +488,7 @@ static void getrunners(unsigned int *restrict running, unsigned int *restrict bl
|
||||
char c;
|
||||
|
||||
if (!isdigit(ent->d_name[0])) continue;
|
||||
- sprintf(tbuf, "/proc/%s/stat", ent->d_name);
|
||||
+ snprintf(tbuf, sizeof(tbuf), "/proc/%s/stat", ent->d_name);
|
||||
|
||||
fd = open(tbuf, O_RDONLY, 0);
|
||||
if (fd == -1) continue;
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
From f57a0301e3adfa5fd456404a200182c7f21da03a Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed, 9 Sep 2020 00:00:00 -0500
|
||||
Subject: [PATCH] top: fix potential SEGV when no tasks were displayable
|
||||
|
||||
This patch fixes a nearly decade old bug discovered by
|
||||
Frederik Deweerdt. His merge request shown below would
|
||||
be an adequate solution except for iterative overhead.
|
||||
|
||||
This alternate patch will represent substantially less
|
||||
overhead for an admittedly extremely rare possibility.
|
||||
|
||||
Reference(s):
|
||||
https://gitlab.com/procps-ng/procps/-/merge_requests/114
|
||||
|
||||
And-thanks-to: Frederik Deweerdt <fdeweerdt@fastly.com>
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
|
||||
This patch has been modified to fit euler os
|
||||
Signed-off-by: chenmingmin <chenmingmin@huawei.com>
|
||||
---
|
||||
top/top.c | 2 ++
|
||||
1 files changed, 2 insertions(+)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index e06a61f..1147938 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -6486,6 +6486,8 @@ static int window_show (WIN_t *q, int wmax) {
|
||||
|
||||
// Display Column Headings -- and distract 'em while we sort (maybe)
|
||||
PUFF("\n%s%s%s", q->capclr_hdr, q->columnhdr, Caps_endline);
|
||||
+ // and just in case 'Monpids' is active but matched no processes ...
|
||||
+ if (!Frame_maxtask) return 1; // 1 for the column header
|
||||
|
||||
if (CHKw(q, Show_FOREST))
|
||||
forest_create(q);
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
From 6e1715d9ebcffd7a673cbacbca4416c42d103c7b Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Sun, 13 Sep 2020 00:00:00 -0500
|
||||
Subject: [PATCH] top: fix additional SEGVs if no tasks were displayable
|
||||
|
||||
This patch is an outgrowth of that commit shown below.
|
||||
|
||||
Many additional potential segmentation faults might be
|
||||
encountered if interactive commands are opened up to a
|
||||
user when a '-p' switch has a single non-existent pid.
|
||||
|
||||
[ always the 'k', 'L', 'r', 'Y' keys & maybe 'v' too ]
|
||||
|
||||
So, this patch will restrict such a loser (oops, user)
|
||||
to a reduced subset of normal commands until he/she/it
|
||||
quits then restarts top with something to be displayed
|
||||
or issues the '=' command overriding that '-p' switch.
|
||||
|
||||
Reference(s):
|
||||
commit f57a0301e3adfa5fd456404a200182c7f21da03a
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 1147938..2afe648 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -5897,6 +5897,8 @@ static void do_key (int ch) {
|
||||
write_rcfile();
|
||||
goto all_done;
|
||||
default: // and now, the real work...
|
||||
+ // and just in case 'Monpids' is active but matched no processes ...
|
||||
+ if (!Frame_maxtask && ch != '=') goto all_done;
|
||||
for (i = 0; i < MAXTBL(key_tab); ++i)
|
||||
if (strchr(key_tab[i].keys, ch)) {
|
||||
key_tab[i].func(ch);
|
||||
--
|
||||
2.22.0.windows.1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: procps-ng
|
||||
Version: 3.3.16
|
||||
Release: 12
|
||||
Release: 13
|
||||
Summary: Utilities that provide system information.
|
||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||
URL: https://sourceforge.net/projects/procps-ng/
|
||||
@ -9,9 +9,19 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
|
||||
Source1: README.md
|
||||
Source2: README.top
|
||||
|
||||
Patch0000: backport-0001-pgrep-check-sanity-of-SC_ARG_MAX.patch
|
||||
Patch0001: backport-0002-top-whack-insidious-bug-surrounding-auto-sized-field.patch
|
||||
Patch0002: backport-0003-top-at-abnormal-end-allow-core-dumps-fix-qualys-bug.patch
|
||||
Patch0003: backport-0004-ps-for-abnormal-end-allow-core-dumps-fix-qualys-bug.patch
|
||||
Patch0004: backport-0005-top-restore-one-line-of-code-to-sig_endpgm-function.patch
|
||||
Patch0005: backport-0006-top-restore-configuration-file-backward-compatibilit.patch
|
||||
Patch0006: backport-0007-Fixes-small-bug-in-struct-proc_t-documentation.patch
|
||||
Patch0007: backport-0008-misc-eliminate-a-couple-of-miscellaneous-gcc-warning.patch
|
||||
Patch0008: backport-0009-top-fix-potential-SEGV-when-no-tasks-were-displayabl.patch
|
||||
Patch0009: backport-0010-top-fix-additional-SEGVs-if-no-tasks-were-displayabl.patch
|
||||
|
||||
Patch9000: feature-add-options-M-and-N-for-top.patch
|
||||
Patch9001: bugfix-top-exit-with-error-when-pid-overflow.patch
|
||||
Patch9002: backport-pgrep-check-sanity-of-SC_ARG_MAX.patch
|
||||
|
||||
BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel
|
||||
|
||||
@ -94,6 +104,9 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
||||
%{_mandir}/translated
|
||||
|
||||
%changelog
|
||||
* Thu Nov 03 2020 xinghe <xinghe1@huawei.com> - 3.3.16-13
|
||||
- sync patchs
|
||||
|
||||
* Wed Sep 23 2020 MarsChan <chenmingmin@huawei.com> - 3.3.16-12
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user