aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-07-01 19:07:24 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-07-01 19:07:24 +0200
commitc9091d8947b6f0e28485eadab11d737e4c910430 (patch)
treec67bb40b3795a589230ed76d3c0d93e44b5e96bd
parentdb31c637fa72cfdc546dd85e10d231a0fdce2b1e (diff)
downloadbusybox-w32-c9091d8947b6f0e28485eadab11d737e4c910430.tar.gz
busybox-w32-c9091d8947b6f0e28485eadab11d737e4c910430.tar.bz2
busybox-w32-c9091d8947b6f0e28485eadab11d737e4c910430.zip
ps: fix SEGV on narrow screens. closes 8176
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--procps/ps.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/procps/ps.c b/procps/ps.c
index c65fa012a..bde5f9485 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -654,8 +654,8 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
654 OPT_l = (1 << ENABLE_SELINUX) * (1 << ENABLE_FEATURE_SHOW_THREADS) * ENABLE_FEATURE_PS_LONG, 654 OPT_l = (1 << ENABLE_SELINUX) * (1 << ENABLE_FEATURE_SHOW_THREADS) * ENABLE_FEATURE_PS_LONG,
655 }; 655 };
656#if ENABLE_FEATURE_PS_LONG 656#if ENABLE_FEATURE_PS_LONG
657 time_t now = now; 657 time_t now = now; /* for compiler */
658 unsigned long uptime; 658 unsigned long uptime = uptime;
659#endif 659#endif
660 /* If we support any options, parse argv */ 660 /* If we support any options, parse argv */
661#if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG 661#if ENABLE_SELINUX || ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_PS_WIDE || ENABLE_FEATURE_PS_LONG
@@ -786,9 +786,11 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
786 786
787 { 787 {
788 int sz = terminal_width - len; 788 int sz = terminal_width - len;
789 char buf[sz + 1]; 789 if (sz >= 0) {
790 read_cmdline(buf, sz, p->pid, p->comm); 790 char buf[sz + 1];
791 puts(buf); 791 read_cmdline(buf, sz, p->pid, p->comm);
792 puts(buf);
793 }
792 } 794 }
793 } 795 }
794 if (ENABLE_FEATURE_CLEAN_UP) 796 if (ENABLE_FEATURE_CLEAN_UP)