aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2006-10-27 09:03:24 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2006-10-27 09:03:24 +0000
commit621204bbf6750f1ba3977b43bb35375ddda6b5ae (patch)
treecd34a619db35dccb76043c1bf118d297e17ac436 /procps
parentd3d004dd3507f841745956a035fff68936378f9c (diff)
downloadbusybox-621204bbf6750f1ba3977b43bb35375ddda6b5ae.tar.gz
busybox-621204bbf6750f1ba3977b43bb35375ddda6b5ae.tar.bz2
get_terminal_width_height: do not pass insanely large values
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 0452a5046..4a917282b 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -41,7 +41,7 @@ int ps_main(int argc, char **argv)
/* if w is given once, GNU ps sets the width to 132,
* if w is given more than once, it is "unlimited"
*/
- if(w_count) {
+ if (w_count) {
terminal_width = (w_count==1) ? 132 : INT_MAX;
} else {
get_terminal_width_height(1, &terminal_width, NULL);
@@ -87,24 +87,24 @@ int ps_main(int argc, char **argv)
}
else
#endif
- if(p->rss == 0)
+ if (p->rss == 0)
len = printf("%5d %-8s %s ", p->pid, p->user, p->state);
else
len = printf("%5d %-8s %6ld %s ", p->pid, p->user, p->rss, p->state);
i = terminal_width-len;
- if(namecmd && namecmd[0]) {
- if(i < 0)
+ if (namecmd && namecmd[0]) {
+ if (i < 0)
i = 0;
- if(strlen(namecmd) > (size_t)i)
+ if (strlen(namecmd) > (size_t)i)
namecmd[i] = 0;
printf("%s\n", namecmd);
} else {
namecmd = p->short_cmd;
- if(i < 2)
+ if (i < 2)
i = 2;
- if(strlen(namecmd) > ((size_t)i-2))
+ if (strlen(namecmd) > ((size_t)i-2))
namecmd[i-2] = 0;
printf("[%s]\n", namecmd);
}