Accepting request 614832 from Base:System
- Reference patch procps-ng-3.3.15-typo.patch this patch add a
missed parenthesis for a nroff macro that is \*We become \*(We
in line 2186 of top/top.1
- Update to procps-ng-3.3.15 (bsc#1092100)
* library: Increment to 8:0:1
No removals, no new functions
Changes: slab and pid structures
* library: Just check for SIGLOST and don't delete it issue #93
* library: Fix integer overflow and LPE in file2strvec CVE-2018-1124
* library: Use size_t for alloc functions CVE-2018-1126
* library: Increase comm size to 64
* pgrep: Fix stack-based buffer overflow CVE-2018-1125
* pgrep: Remove >15 warning as comm can be longer issue #92
* ps: Fix buffer overflow in output buffer, causing DOS CVE-2018-1123
* ps: Increase command name selection field to 64
* top: Don't use cwd for location of config CVE-2018-1122
- Increase so major number
OBS-URL: https://build.opensuse.org/request/show/614832
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/procps?expand=0&rev=112
This commit is contained in:
@@ -1,3 +1,28 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 6 10:56:31 UTC 2018 - werner@suse.de
|
||||
|
||||
- Reference patch procps-ng-3.3.15-typo.patch this patch add a
|
||||
missed parenthesis for a nroff macro that is \*We become \*(We
|
||||
in line 2186 of top/top.1
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 5 09:24:20 UTC 2018 - werner@suse.de
|
||||
|
||||
- Update to procps-ng-3.3.15 (bsc#1092100)
|
||||
* library: Increment to 8:0:1
|
||||
No removals, no new functions
|
||||
Changes: slab and pid structures
|
||||
* library: Just check for SIGLOST and don't delete it issue #93
|
||||
* library: Fix integer overflow and LPE in file2strvec CVE-2018-1124
|
||||
* library: Use size_t for alloc functions CVE-2018-1126
|
||||
* library: Increase comm size to 64
|
||||
* pgrep: Fix stack-based buffer overflow CVE-2018-1125
|
||||
* pgrep: Remove >15 warning as comm can be longer issue #92
|
||||
* ps: Fix buffer overflow in output buffer, causing DOS CVE-2018-1123
|
||||
* ps: Increase command name selection field to 64
|
||||
* top: Don't use cwd for location of config CVE-2018-1122
|
||||
- Increase so major number
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 12 09:26:45 UTC 2018 - werner@suse.de
|
||||
|
||||
|
||||
+8
-5
@@ -16,20 +16,20 @@
|
||||
#
|
||||
|
||||
|
||||
%define somajor 6
|
||||
%define somajor 7
|
||||
%define libname libprocps%{somajor}
|
||||
%bcond_with bin2usr
|
||||
%bcond_with pidof
|
||||
Name: procps
|
||||
Version: 3.3.14
|
||||
Version: 3.3.15
|
||||
Release: 0
|
||||
Summary: The ps utilities for /proc
|
||||
#Alternate: https://gitlab.com/procps-ng/procps/repository/archive.tar.bz2?ref=v3.3.14
|
||||
#Alternate: https://gitlab.com/procps-ng/procps/repository/archive.tar.bz2?ref=v3.3.15
|
||||
#Also: http://gitorious.org/procps/
|
||||
License: GPL-2.0-or-later AND LGPL-2.1-or-later
|
||||
Group: System/Monitoring
|
||||
Url: http://sf.net/projects/procps-ng/
|
||||
Source: http://downloads.sourceforge.net/project/procps-ng/Production/procps-ng-3.3.14.tar.xz
|
||||
Source: http://downloads.sourceforge.net/project/procps-ng/Production/procps-ng-3.3.15.tar.xz
|
||||
Source1: procps-rpmlintrc
|
||||
Patch0: procps-ng-3.3.9-watch.patch
|
||||
Patch1: procps-v3.3.3-ia64.diff
|
||||
@@ -57,6 +57,8 @@ Patch31: procps-ng-3.3.8-ignore-scan_unevictable_pages.patch
|
||||
Patch32: procps-ng-3.3.10-errno.patch
|
||||
# PATCH-FEATURE-SUSE -- Let upstream pmap behave simialr to old suse pmap
|
||||
Patch33: procps-ng-3.3.11-pmap4suse.patch
|
||||
# PATCH-TYPO-SUSE
|
||||
Patch34: procps-ng-3.3.15-typo.patch
|
||||
|
||||
BuildRequires: automake
|
||||
BuildRequires: dejagnu
|
||||
@@ -144,7 +146,8 @@ the process information pseudo-file system.
|
||||
%patch28
|
||||
%patch31 -p1
|
||||
%patch32
|
||||
%patch33
|
||||
%patch33 -b .pmap4us
|
||||
%patch34
|
||||
|
||||
%build
|
||||
#
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
tty_to_dev;
|
||||
--- proc/sysinfo.c
|
||||
+++ proc/sysinfo.c 2018-04-04 11:33:26.306886237 +0000
|
||||
@@ -45,7 +45,8 @@
|
||||
@@ -47,7 +47,8 @@
|
||||
#endif
|
||||
#include <elf.h>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
long page_bytes; /* this architecture's page size */
|
||||
|
||||
#define BAD_OPEN_MESSAGE \
|
||||
@@ -1152,7 +1153,11 @@ out:
|
||||
@@ -1166,7 +1167,11 @@ out:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
// ought to count CPUs in /proc/stat instead of relying
|
||||
// on glibc, which foolishly tries to parse /proc/cpuinfo
|
||||
// note: that may have been the case but now /proc/stat
|
||||
@@ -1167,4 +1172,8 @@ void cpuinfo (void) {
|
||||
@@ -1181,4 +1186,8 @@ void cpuinfo (void) {
|
||||
smp_num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if (smp_num_cpus<1) /* SPARC glibc is buggy */
|
||||
smp_num_cpus=1;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
}
|
||||
--- proc/sysinfo.c
|
||||
+++ proc/sysinfo.c 2018-04-04 11:17:32.480409601 +0000
|
||||
@@ -781,7 +781,10 @@ nextline:
|
||||
@@ -783,7 +783,10 @@ nextline:
|
||||
kb_main_cached = kb_page_cache + kb_slab_reclaimable;
|
||||
if ((ev=getenv("PS_FULL_CACHE")))
|
||||
kb_main_cached += kb_swap_cached + kb_nfs_unstable;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
--- top/top.c
|
||||
+++ top/top.c 2018-04-04 12:09:16.087193018 +0000
|
||||
@@ -2458,7 +2458,11 @@ static void zap_fieldstab (void) {
|
||||
@@ -2478,7 +2478,11 @@ static void zap_fieldstab (void) {
|
||||
Cpu_pmax = 99.9;
|
||||
if (Rc.mode_irixps && smp_num_cpus > 1 && !Thread_mode) {
|
||||
Cpu_pmax = 100.0 * smp_num_cpus;
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -698,6 +699,7 @@ void meminfo(void){
|
||||
@@ -700,6 +701,7 @@ void meminfo(void){
|
||||
int linux_version_code = procps_linux_version();
|
||||
mem_table_struct findme = { namebuf, NULL};
|
||||
mem_table_struct *found;
|
||||
@@ -75,7 +75,7 @@
|
||||
char *head;
|
||||
char *tail;
|
||||
static const mem_table_struct mem_table[] = {
|
||||
@@ -777,6 +779,8 @@ nextline:
|
||||
@@ -779,6 +781,8 @@ nextline:
|
||||
kb_inactive = kb_inact_dirty + kb_inact_clean + kb_inact_laundry;
|
||||
}
|
||||
kb_main_cached = kb_page_cache + kb_slab_reclaimable;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
pmap.c | 48 ++++++++++++++++++++++++++++++++-----------
|
||||
pmap.c | 47 ++++++++++++++++++++++++++++++++-----------
|
||||
testsuite/pmap.test/pmap.exp | 17 +++++++--------
|
||||
2 files changed, 44 insertions(+), 21 deletions(-)
|
||||
2 files changed, 44 insertions(+), 20 deletions(-)
|
||||
|
||||
--- pmap.c
|
||||
+++ pmap.c 2018-04-04 12:52:03.219187662 +0000
|
||||
@@ -48,7 +48,9 @@ const char *nls_Address,
|
||||
+++ pmap.c 2018-06-05 09:37:34.404294888 +0000
|
||||
@@ -49,7 +49,9 @@ const char *nls_Address,
|
||||
*nls_Kbytes,
|
||||
*nls_Mode,
|
||||
*nls_RSS,
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
static void nls_initialize(void)
|
||||
{
|
||||
@@ -72,7 +74,9 @@ static void nls_initialize(void)
|
||||
@@ -73,7 +75,9 @@ static void nls_initialize(void)
|
||||
nls_Kbytes = _("Kbytes");
|
||||
nls_Mode = _("Mode");
|
||||
nls_RSS = _("RSS");
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
static int justify_print(const char *str, int width, int right)
|
||||
@@ -140,10 +144,10 @@ static int d_option;
|
||||
@@ -141,10 +145,10 @@ static int d_option;
|
||||
static int n_option;
|
||||
static int N_option;
|
||||
static int q_option;
|
||||
@@ -39,8 +39,8 @@
|
||||
|
||||
static unsigned shm_minor = ~0u;
|
||||
|
||||
@@ -521,12 +525,17 @@ static int one_proc(proc_t * p)
|
||||
unsigned KLONG diff = 0;
|
||||
@@ -522,12 +526,17 @@ static int one_proc(const proc_t * p)
|
||||
char perms[32] = "";
|
||||
const char *cp2 = NULL;
|
||||
unsigned long long rss = 0ull;
|
||||
+ unsigned long long pss = 0ull;
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
/* Overkill, but who knows what is proper? The "w" prog uses
|
||||
* the tty width to determine this.
|
||||
@@ -555,13 +564,15 @@ static int one_proc(proc_t * p)
|
||||
@@ -557,13 +566,15 @@ static int one_proc(const proc_t * p)
|
||||
if (x_option) {
|
||||
maxw1 = 16;
|
||||
if (sizeof(KLONG) == 4) maxw1 = 8;
|
||||
@@ -74,7 +74,7 @@
|
||||
maxw5 = justify_print(nls_Mode, maxw5, 0);
|
||||
justify_print(nls_Mapping, 0, 0);
|
||||
}
|
||||
@@ -603,6 +614,11 @@ static int one_proc(proc_t * p)
|
||||
@@ -603,6 +614,11 @@ static int one_proc(const proc_t * p)
|
||||
total_rss += smap_value;
|
||||
continue;
|
||||
}
|
||||
@@ -86,15 +86,14 @@
|
||||
if (strcmp("Shared_Dirty", smap_key) == 0) {
|
||||
shared_dirty = smap_value;
|
||||
total_shared_dirty += smap_value;
|
||||
@@ -614,16 +630,19 @@ static int one_proc(proc_t * p)
|
||||
continue;
|
||||
@@ -615,15 +631,19 @@ static int one_proc(const proc_t * p)
|
||||
}
|
||||
if (strcmp("Swap", smap_key) == 0) {
|
||||
- /*doesn't matter as long as last */
|
||||
- printf("%0*" KLF "x %*lu %*llu %*llu %*s %s\n",
|
||||
/* doesn't matter as long as last */
|
||||
- if (cp2) printf("%0*" KLF "x %*lu %*llu %*llu %*s %s\n",
|
||||
+ swap = smap_value;
|
||||
+ total_swap += smap_value;
|
||||
+ printf("%0*" KLF "x %*lu %*llu %*llu %*llu %*llu %*s %s\n",
|
||||
+ if (cp2) printf("%0*" KLF "x %*lu %*llu %*llu %*llu %*llu %*s %s\n",
|
||||
maxw1, start,
|
||||
maxw2, (unsigned long)(diff >> 10),
|
||||
maxw3, rss,
|
||||
@@ -106,10 +105,10 @@
|
||||
/* reset some counters */
|
||||
- rss = shared_dirty = private_dirty = 0ull;
|
||||
+ rss = pss = shared_dirty = private_dirty = swap = 0ull;
|
||||
diff = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -654,7 +673,6 @@ static int one_proc(proc_t * p)
|
||||
start = diff = end = 0;
|
||||
perms[0] = '\0';
|
||||
cp2 = NULL;
|
||||
@@ -656,7 +676,6 @@ static int one_proc(const proc_t * p)
|
||||
if (perms[3] == 's')
|
||||
total_shared += diff;
|
||||
if (perms[3] == 'p') {
|
||||
@@ -117,7 +116,7 @@
|
||||
if (perms[1] == 'w')
|
||||
total_private_writeable += diff;
|
||||
else
|
||||
@@ -706,17 +724,21 @@ static int one_proc(proc_t * p)
|
||||
@@ -708,17 +727,21 @@ static int one_proc(const proc_t * p)
|
||||
justify_print("----------------", maxw1, 0);
|
||||
justify_print("-------", maxw2, 1);
|
||||
justify_print("-------", maxw3, 1);
|
||||
@@ -141,7 +140,7 @@
|
||||
}
|
||||
if (d_option) {
|
||||
printf
|
||||
@@ -1023,16 +1045,18 @@ int main(int argc, char **argv)
|
||||
@@ -1028,16 +1051,18 @@ int main(int argc, char **argv)
|
||||
while ((c = getopt_long(argc, argv, "xXrdqA:hVcC:nN:p", longopts, NULL)) != -1)
|
||||
switch (c) {
|
||||
case 'x':
|
||||
@@ -163,7 +162,7 @@
|
||||
case 'q':
|
||||
q_option = 1;
|
||||
--- testsuite/pmap.test/pmap.exp
|
||||
+++ testsuite/pmap.test/pmap.exp 2018-04-04 12:47:45.452023967 +0000
|
||||
+++ testsuite/pmap.test/pmap.exp 2018-06-05 09:23:53.955370363 +0000
|
||||
@@ -8,16 +8,16 @@ set pmap_procname "${mypid}:\\s+\\S+\[^\
|
||||
set pmap_initname "1:\\s+\\S+\[^\\r\]+\\s+"
|
||||
set pmap_std_header $pmap_procname
|
||||
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
---
|
||||
top/top.1 | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- top/top.1
|
||||
+++ top/top.1 2018-06-05 12:46:41.483212158 +0000
|
||||
@@ -2183,7 +2183,7 @@ While not intended to be edited manually
|
||||
.fi
|
||||
|
||||
If a valid absolute path to the rcfile cannot be established, customizations
|
||||
-made to a running \*We will be impossible to preserve.
|
||||
+made to a running \*(We will be impossible to preserve.
|
||||
|
||||
.\" ......................................................................
|
||||
.SS 6b. ADDING INSPECT Entries
|
||||
BIN
Binary file not shown.
@@ -44,7 +44,7 @@
|
||||
sort_list = NULL;
|
||||
--- ps/output.c
|
||||
+++ ps/output.c 2018-04-04 11:14:33.915688098 +0000
|
||||
@@ -135,6 +135,7 @@ static int sr_ ## NAME (const proc_t* P,
|
||||
@@ -134,6 +134,7 @@ static int sr_ ## NAME (const proc_t* P,
|
||||
#define cook_time(P) (P->utime + P->stime) / Hertz
|
||||
|
||||
#define cook_etime(P) (((unsigned long long)seconds_since_boot >= (P->start_time / Hertz)) ? ((unsigned long long)seconds_since_boot - (P->start_time / Hertz)) : 0)
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
#define CMP_COOKED_TIME(NAME) \
|
||||
static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
|
||||
@@ -508,11 +509,11 @@ static int pr_etimes(char *restrict cons
|
||||
@@ -507,11 +508,11 @@ static int pr_etimes(char *restrict cons
|
||||
static int pr_c(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
unsigned long long total_time; /* jiffies used by this process */
|
||||
unsigned pcpu = 0; /* scaled %cpu, 99 means 99% */
|
||||
@@ -67,7 +67,7 @@
|
||||
if (pcpu > 99U) pcpu = 99U;
|
||||
return snprintf(outbuf, COLWID, "%2u", pcpu);
|
||||
}
|
||||
@@ -520,11 +521,11 @@ static int pr_c(char *restrict const out
|
||||
@@ -519,11 +520,11 @@ static int pr_c(char *restrict const out
|
||||
static int pr_pcpu(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
unsigned long long total_time; /* jiffies used by this process */
|
||||
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
|
||||
@@ -82,7 +82,7 @@
|
||||
if (pcpu > 999U)
|
||||
return snprintf(outbuf, COLWID, "%u", pcpu/10U);
|
||||
return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U);
|
||||
@@ -533,11 +534,11 @@ static int pr_pcpu(char *restrict const
|
||||
@@ -532,11 +533,11 @@ static int pr_pcpu(char *restrict const
|
||||
static int pr_cp(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
unsigned long long total_time; /* jiffies used by this process */
|
||||
unsigned pcpu = 0; /* scaled %cpu, 999 means 99.9% */
|
||||
|
||||
@@ -12,7 +12,7 @@ Index: procps-3.2.8/top.c
|
||||
|
||||
--- top/top.c
|
||||
+++ top/top.c 2018-04-04 11:33:59.278280201 +0000
|
||||
@@ -3575,7 +3575,13 @@ static void before (char *me) {
|
||||
@@ -3600,7 +3600,13 @@ static void before (char *me) {
|
||||
sa.sa_flags = 0;
|
||||
for (i = SIGRTMAX; i; i--) {
|
||||
switch (i) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
--- top/top.c
|
||||
+++ top/top.c 2018-04-04 11:49:56.472660056 +0000
|
||||
@@ -1688,9 +1688,9 @@ static inline const char *make_str_utf8
|
||||
@@ -1704,9 +1704,9 @@ static inline const char *make_str_utf8
|
||||
static const char *scale_mem (int target, unsigned long num, int width, int justr) {
|
||||
// SK_Kb SK_Mb SK_Gb SK_Tb SK_Pb SK_Eb
|
||||
#ifdef BOOST_MEMORY
|
||||
@@ -16,7 +16,7 @@
|
||||
#endif
|
||||
static char buf[SMLBUFSIZ];
|
||||
float scaled_num;
|
||||
@@ -1702,7 +1702,7 @@ static const char *scale_mem (int target
|
||||
@@ -1718,7 +1718,7 @@ static const char *scale_mem (int target
|
||||
goto end_justifies;
|
||||
|
||||
scaled_num = num;
|
||||
|
||||
@@ -1,89 +1,66 @@
|
||||
---
|
||||
proc/readproc.c | 49 +++++++++++++++++++++++++------------------------
|
||||
1 file changed, 25 insertions(+), 24 deletions(-)
|
||||
proc/readproc.c | 20 ++++++++++----------
|
||||
1 file changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
--- proc/readproc.c
|
||||
+++ proc/readproc.c 2018-04-04 11:13:11.593199324 +0000
|
||||
@@ -644,7 +644,7 @@ static int file2str(const char *director
|
||||
if (ub->buf) ub->buf[0] = '\0';
|
||||
+++ proc/readproc.c 2018-06-05 08:54:06.408030693 +0000
|
||||
@@ -669,7 +669,7 @@ static int file2str(const char *director
|
||||
else ub->buf = xcalloc((ub->siz = buffGRW));
|
||||
sprintf(path, "%s/%s", directory, what);
|
||||
len = snprintf(path, sizeof path, "%s/%s", directory, what);
|
||||
if (len <= 0 || (size_t)len >= sizeof path) return -1;
|
||||
- if (-1 == (fd = open(path, O_RDONLY, 0))) return -1;
|
||||
+ if (-1 == (fd = open(path, O_RDONLY, O_NOATIME))) return -1;
|
||||
while (0 < (num = read(fd, ub->buf + tot_read, ub->siz - tot_read))) {
|
||||
tot_read += num;
|
||||
if (tot_read < ub->siz) break;
|
||||
@@ -659,41 +659,42 @@ static int file2str(const char *director
|
||||
|
||||
@@ -689,25 +689,25 @@ static int file2str(const char *director
|
||||
static char** file2strvec(const char* directory, const char* what) {
|
||||
char buf[2048]; /* read buf bytes at a time */
|
||||
- char *p, *rbuf = 0, *endbuf, **q, **ret;
|
||||
char *p, *rbuf = 0, *endbuf, **q, **ret, *strp;
|
||||
- int fd, tot = 0, n, c, end_of_file = 0;
|
||||
- int align;
|
||||
+ char *p, *rbuf = (char*)0, *endbuf, **q, **ret;
|
||||
+ int fd, c;
|
||||
+ int fd, c, end_of_file = 0;
|
||||
+ ssize_t n, align, tot = 0;
|
||||
|
||||
sprintf(buf, "%s/%s", directory, what);
|
||||
const int len = snprintf(buf, sizeof buf, "%s/%s", directory, what);
|
||||
if(len <= 0 || (size_t)len >= sizeof buf) return NULL;
|
||||
- fd = open(buf, O_RDONLY, 0);
|
||||
+ fd = open(buf, O_RDONLY, O_NOATIME);
|
||||
if(fd==-1) return NULL;
|
||||
|
||||
/* read whole file into a memory buffer, allocating as we go */
|
||||
- while ((n = read(fd, buf, sizeof buf - 1)) >= 0) {
|
||||
while ((n = read(fd, buf, sizeof buf - 1)) >= 0) {
|
||||
- if (n < (int)(sizeof buf - 1))
|
||||
- end_of_file = 1;
|
||||
- if (n == 0 && rbuf == 0) {
|
||||
- close(fd);
|
||||
- return NULL; /* process died between our open and read */
|
||||
+ if (n < sizeof buf - 1)
|
||||
end_of_file = 1;
|
||||
- if (n <= 0 && tot <= 0) { /* nothing read now, nothing read before */
|
||||
+ if (n <= 0 && tot <= 0) /* nothing read now, nothing read before */
|
||||
break; /* process died between our open and read */
|
||||
- }
|
||||
+ do {
|
||||
+ n = read(fd, buf, sizeof(buf) - 1);
|
||||
if (n < 0) {
|
||||
- if (rbuf)
|
||||
- free(rbuf);
|
||||
- close(fd);
|
||||
- return NULL; /* read error */
|
||||
+ tot = 0;
|
||||
+ break; /* read error! */
|
||||
+ }
|
||||
+ if (n == 0) {
|
||||
+ if(rbuf == (char*)0)
|
||||
+ tot = 0; /* process died between our open and read */
|
||||
+ break; /* we're done */
|
||||
+
|
||||
/* ARG_LEN is our guesstimated median length of a command-line argument
|
||||
or environment variable (the minimum is 1, the maximum is 131072) */
|
||||
#define ARG_LEN 64
|
||||
- if (tot >= INT_MAX / (ARG_LEN + (int)sizeof(char*)) * ARG_LEN - n) {
|
||||
+ if (tot >= INT_MAX / (ARG_LEN + sizeof(char*)) * ARG_LEN - n) {
|
||||
end_of_file = 1; /* integer overflow: null-terminate and break */
|
||||
n = 0; /* but tot > 0 */
|
||||
}
|
||||
- if (end_of_file && (n == 0 || buf[n-1]))/* last read char not null */
|
||||
- buf[n++] = '\0'; /* so append null-terminator */
|
||||
rbuf = xrealloc(rbuf, tot + n); /* allocate more memory */
|
||||
memcpy(rbuf + tot, buf, n); /* copy buffer into it */
|
||||
tot += n; /* increment total byte ctr */
|
||||
- if (end_of_file)
|
||||
- break;
|
||||
- }
|
||||
+ } while (n >= (sizeof(buf) - 1));
|
||||
+
|
||||
close(fd);
|
||||
- if (n <= 0 && !end_of_file) {
|
||||
+
|
||||
+ if (tot == 0) {
|
||||
if (rbuf) free(rbuf);
|
||||
- return NULL; /* read error */
|
||||
+ return NULL; /* read error */
|
||||
+ }
|
||||
+ if (rbuf[tot-1]) { /* last read char not null */
|
||||
+ rbuf = xrealloc(rbuf, tot + 1); /* allocate more memory */
|
||||
+ rbuf[tot++] = '\0'; /* and append null-terminator */
|
||||
}
|
||||
+
|
||||
endbuf = rbuf + tot; /* count space for pointers */
|
||||
align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1));
|
||||
for (c = 0, p = rbuf; p < endbuf; p++) {
|
||||
@@ -726,7 +727,7 @@ static int read_unvectored(char *restric
|
||||
unsigned n = 0;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s", whom, what);
|
||||
- fd = open(path, O_RDONLY);
|
||||
+ fd = open(path, O_RDONLY, O_NOATIME);
|
||||
if(fd==-1) return 0;
|
||||
|
||||
for(;;){
|
||||
@@ -735,7 +735,7 @@ static char** file2strvec(const char* di
|
||||
c = sizeof(char*); /* one extra for NULL term */
|
||||
for (p = rbuf; p < endbuf; p++) {
|
||||
if (!*p || *p == '\n') {
|
||||
- if (c >= INT_MAX - (tot + (int)sizeof(char*) + align)) break;
|
||||
+ if (c >= INT_MAX - (tot + sizeof(char*) + align)) break;
|
||||
c += sizeof(char*);
|
||||
}
|
||||
if (*p == '\n')
|
||||
@@ -747,7 +747,7 @@ static char** file2strvec(const char* di
|
||||
q = ret = (char**) (endbuf+align); /* ==> free(*ret) to dealloc */
|
||||
for (strp = p = rbuf; p < endbuf; p++) {
|
||||
if (!*p) { /* NUL char implies that */
|
||||
- if (c < 2 * (int)sizeof(char*)) break;
|
||||
+ if (c < 2 * sizeof(char*)) break;
|
||||
c -= sizeof(char*);
|
||||
*q++ = strp; /* point ptrs to the strings */
|
||||
strp = p+1; /* next string -> next char */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
--- Makefile.am
|
||||
+++ Makefile.am 2018-04-04 12:28:14.937957527 +0000
|
||||
@@ -165,7 +165,7 @@ else
|
||||
@@ -164,7 +164,7 @@ else
|
||||
slabtop_LDADD = $(LDADD) @NCURSES_LIBS@
|
||||
endif
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
2 files changed, 18 insertions(+), 3 deletions(-)
|
||||
|
||||
--- w.1
|
||||
+++ w.1 2017-04-26 12:31:23.721421873 +0000
|
||||
+++ w.1 2018-06-05 07:04:14.040265663 +0000
|
||||
@@ -36,6 +36,9 @@ and a "w \-u".
|
||||
\fB\-s\fR, \fB\-\-short\fR
|
||||
Use the short format. Don't print the login time, JCPU or PCPU times.
|
||||
@@ -16,8 +16,8 @@
|
||||
Toggle printing the
|
||||
.B from
|
||||
--- w.c
|
||||
+++ w.c 2017-04-26 12:23:20.394822856 +0000
|
||||
@@ -375,7 +375,7 @@ static const proc_t *getproc(const utmp_
|
||||
+++ w.c 2018-06-05 07:04:14.040265663 +0000
|
||||
@@ -379,7 +379,7 @@ static const proc_t *getproc(const utmp_
|
||||
}
|
||||
|
||||
static void showinfo(utmp_t * u, int formtype, int maxcmd, int from,
|
||||
@@ -26,7 +26,7 @@
|
||||
{
|
||||
unsigned long long jcpu;
|
||||
int ut_pid_found;
|
||||
@@ -405,7 +405,13 @@ static void showinfo(utmp_t * u, int for
|
||||
@@ -409,7 +409,13 @@ static void showinfo(utmp_t * u, int for
|
||||
strncpy(uname, u->ut_user, UT_NAMESIZE);
|
||||
|
||||
if (formtype) {
|
||||
@@ -41,7 +41,7 @@
|
||||
if (from)
|
||||
print_from(u, ip_addresses, fromlen);
|
||||
print_logintime(u->ut_time, stdout);
|
||||
@@ -455,6 +461,7 @@ static void __attribute__ ((__noreturn__
|
||||
@@ -459,6 +465,7 @@ static void __attribute__ ((__noreturn__
|
||||
fputs(_(" -h, --no-header do not print header\n"),out);
|
||||
fputs(_(" -u, --no-current ignore current process username\n"),out);
|
||||
fputs(_(" -s, --short short format\n"),out);
|
||||
@@ -49,7 +49,7 @@
|
||||
fputs(_(" -f, --from show remote hostname field\n"),out);
|
||||
fputs(_(" -o, --old-style old style output\n"),out);
|
||||
fputs(_(" -i, --ip-addr display IP address instead of hostname (if possible)\n"), out);
|
||||
@@ -491,6 +498,7 @@ int main(int argc, char **argv)
|
||||
@@ -495,6 +502,7 @@ int main(int argc, char **argv)
|
||||
{"no-header", no_argument, NULL, 'h'},
|
||||
{"no-current", no_argument, NULL, 'u'},
|
||||
{"short", no_argument, NULL, 's'},
|
||||
@@ -57,7 +57,7 @@
|
||||
{"from", no_argument, NULL, 'f'},
|
||||
{"old-style", no_argument, NULL, 'o'},
|
||||
{"ip-addr", no_argument, NULL, 'i'},
|
||||
@@ -512,7 +520,7 @@ int main(int argc, char **argv)
|
||||
@@ -516,7 +524,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
while ((ch =
|
||||
@@ -66,7 +66,7 @@
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
header = 0;
|
||||
@@ -523,6 +531,10 @@ int main(int argc, char **argv)
|
||||
@@ -527,6 +535,10 @@ int main(int argc, char **argv)
|
||||
case 's':
|
||||
longform = 0;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user