From cc5c6955be980019bcee61b841555fce344f6357 Mon Sep 17 00:00:00 2001 From: albert <> Date: Tue, 18 Feb 2003 03:51:03 +0000 Subject: [PATCH] warning directs users to the FAQ --- NEWS | 7 ++++++- proc/readproc.c | 11 ++++++----- procps.lsm | 6 +++--- ps/common.h | 2 +- ps/display.c | 1 - ps/parser.c | 13 +++++++++++-- ps/select.c | 3 +-- 7 files changed, 28 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 5787a254..0a33583e 100644 --- a/NEWS +++ b/NEWS @@ -1,14 +1,19 @@ +procps-3.1.6 --> procps-3.1.7 + +ps: warning directs users to the FAQ + procps-3.1.5 --> procps-3.1.6 handle the 2.5.61 kernel top: memory leak fixed ps: new --ppid option selects by PPID -watch: new --no-title option #179862 +watch: new --no-title option #179862 handle SPARC Linux badness rare crash fixed compile with gcc 2.91.xx again more informative "ps --info" README update +ps: compare more with "ps -C verylongname" #178127 procps-3.1.4 --> procps-3.1.5 diff --git a/proc/readproc.c b/proc/readproc.c index 941d7a83..2c6162fa 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -235,20 +235,21 @@ ENTER(0x220); P->fgid = strtol(S,&S,10); continue; case_Name:{ - int i = 0; - while(i < sizeof P->cmd - 1){ + unsigned u = 0; + while(u < sizeof P->cmd - 1u){ int c = *S++; if(unlikely(c=='\n')) break; - if(unlikely(c=='\0')) return; // should never happen + if(unlikely(c=='\0')) break; // should never happen if(unlikely(c=='\\')){ c = *S++; if(c=='\n') break; // should never happen if(!c) break; // should never happen if(c=='n') c='\n'; // else we assume it is '\\' } - P->cmd[i++] = c; + P->cmd[u++] = c; } - P->cmd[i] = '\0'; + P->cmd[u] = '\0'; + S--; // put back the '\n' or '\0' continue; } case_PPid: diff --git a/procps.lsm b/procps.lsm index 78e06ec6..6ed2b3b9 100644 --- a/procps.lsm +++ b/procps.lsm @@ -1,15 +1,15 @@ Begin4 Title: procps Version: 3.1.6 -Entered-date: 2002-12-14 +Entered-date: 2003-2-17 Description: Linux system utilities Keywords: procps /proc libproc sysctl pmap ps uptime tload free w top vmstat watch skill snice kill pgrep pkill Author: Albert Cahalan, Michael K. Johnson, Jim Warner, etc. Maintained-by: various Primary-site: http://procps.sf.net/ - 236kB procps-3.1.6.tar.gz + 238kB procps-3.1.6.tar.gz Alternate-site: http://www.debian.org/Packages/unstable/base/procps.html - 236kB procps-3.1.6.tar.gz + 238kB procps-3.1.6.tar.gz Copying-policy: mixed End diff --git a/ps/common.h b/ps/common.h index 5cea9341..48d4cff5 100644 --- a/ps/common.h +++ b/ps/common.h @@ -148,7 +148,7 @@ typedef union sel_union { uid_t uid; gid_t gid; dev_t tty; - char cmd[8]; /* this is _not_ \0 terminated */ + char cmd[16]; /* this is _not_ \0 terminated */ } sel_union; typedef struct selection_node { diff --git a/ps/display.c b/ps/display.c index bb791076..2437a215 100644 --- a/ps/display.c +++ b/ps/display.c @@ -246,7 +246,6 @@ static void simple_spew(void){ exit(1); } memset(&buf, '#', sizeof(proc_t)); - /* use "ps_" prefix to catch library mismatch */ while(ps_readproc(ptp,&buf)){ if(want_this_proc(&buf)) show_one_proc(&buf); if(buf.cmdline) free((void*)*buf.cmdline); // ought to reuse diff --git a/ps/parser.c b/ps/parser.c index 6f250043..a0d0edd9 100644 --- a/ps/parser.c +++ b/ps/parser.c @@ -121,7 +121,7 @@ static const char *parse_gid(char *str, sel_union *ret){ } static const char *parse_cmd(char *str, sel_union *ret){ - strncpy(ret->cmd, str, 8); /* strncpy pads to end */ + strncpy(ret->cmd, str, sizeof ret->cmd); // strncpy pads to end return 0; } @@ -1130,8 +1130,17 @@ try_bsd: err2 = select_bits_setup(); if(err2) goto total_failure; + // Feel a need to patch this out? First of all, read the FAQ. + // Second of all, talk to me. Without this warning, people can + // get seriously confused. Ask yourself if users would freak out + // about "ps -aux" suddenly changing behavior if a user "x" were + // added to the system. if(!(personality & PER_FORCE_BSD)) - fprintf(stderr, "Bad syntax, perhaps a bogus '-'?\n"); + fprintf(stderr, "Warning: bad '-'? See http://procps.sf.net/faq.html\n"); + // Remember: contact albert@users.sf.net or procps-feedback@lists.sf.net + // if you should feel tempted. Be damn sure you understand all + // the issues. The same goes for other stuff too, BTW. Please ask. + // I'm happy to justify various implementation choices. choose_dimensions(); return 0; diff --git a/ps/select.c b/ps/select.c index aecc59d4..ef41972b 100644 --- a/ps/select.c +++ b/ps/select.c @@ -106,9 +106,8 @@ static int proc_was_listed(proc_t *buf){ break; case SEL_TTY : return_if_match(tty,tty); break; case SEL_SESS: return_if_match(session,pid); - /* TODO Should use a long long cast for performance */ break; case SEL_COMM: i=sn->n; while(i--) - if(!strncmp( buf->cmd, (*(sn->u+i)).cmd, 8 )) return 1; + if(!strncmp( buf->cmd, (*(sn->u+i)).cmd, 15 )) return 1; -- 2.40.0