]> granicus.if.org Git - procps-ng/commitdiff
top: address the argument parsing quirk involving '-h'
authorJim Warner <james.warner@comcast.net>
Wed, 17 May 2017 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Mon, 22 May 2017 11:34:38 +0000 (21:34 +1000)
There exists the possibility that a 'putp' call can be
issued before the 'setupterm' invocation has occurred,
as is reflected in a bugzilla report referenced below.

Strangely, such a SEGV isn't always triggered as logic
would suggest it ought to be. I experienced a fault in
these environments with the associated curses version:
. archlinux, procps-ng 3.3.12, ncurses 6.0.20170429
. fedora-25, procps-ng 3.3.10, ncurses 6.0.20160709
. opensuse-42.2, procps-ng 3.3.9, ncurses 5.9.20140201
. gentoo, procps-ng 3.3.12, ncurses 6.0.20150808
. slackw-14.2, procps-ng 3.3.12, ncurses 6.0.20160910

Whereas under these environments there was no problem:
. ubuntu-17.04, procps-ng 3.3.12, ncurses 6.0.20160625
. debian-test, procps-ng 3.3.12, ncurses 6.0.20161126
. mageia-5.1, procps-ng 3.3.9, ncurses 5.9.20140323

[ as an aside, the expected result in the bug report ]
[ is incorrect and should mention the '1' parameter. ]

[ however, until release 3.3.13 when the '1' becomes ]
[ a valid switch, numbers are not detected when used ]
[ with any switch which doesn't require an argument. ]

[ you're welcome to treat that as a separate bugglet ]

Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1450429

Signed-off-by: Jim Warner <james.warner@comcast.net>
NEWS
top/top.c

diff --git a/NEWS b/NEWS
index 6a3a2c7d0b7072c6eb05efad7f69ad790e291435..e0be152add5b8fbba01543d41f6753f6799fedbf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ procps-ng-NEXT
   * top: provide command line switch for CPU States
   * top: provides more accurate cpu usage at startup
   * top: display NUMA node under which a thread ran
+  * top: fix argument parsing quirk resulting in SEGV      Redhat #1450429
   * watch: define HOST_NAME_MAX where not defined          Debian #830734
 
 procps-ng-3.3.12
index a703ef14160bc8e666b87d931c6422ddb4838b1b..b72e949cbffe3d1a3dbbee946dca17181a71d431 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -548,7 +548,7 @@ static void bye_bye (const char *str) {
       fputs(str, stderr);
       exit(EXIT_FAILURE);
    }
-   if (Batch) putp("\n");
+   if (Batch) fputs("\n", stdout);
    exit(EXIT_SUCCESS);
 } // end: bye_bye