NetBSD Problem Report #31908

From www@netbsd.org  Mon Oct 24 15:58:38 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id 1DD1163B9F9; Mon, 24 Oct 2005 15:58:38 +0000 (UTC)
Message-Id: <20051024155838.1DD1163B9F9@narn.netbsd.org>
Date: Mon, 24 Oct 2005 15:58:38 +0000 (UTC)
From: zafer@gmx.org
Reply-To: zafer@gmx.org
To: gnats-bugs@netbsd.org
Subject: top doesn't check invalid values
X-Send-Pr-Version: www-1.0

>Number:         31908
>Category:       bin
>Synopsis:       top doesn't check invalid values
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 24 15:59:00 +0000 2005
>Last-Modified:  Sat Feb 20 23:55:01 +0000 2010
>Originator:     Zafer Aydogan
>Release:        3.99.10
>Organization:
>Environment:
>Description:
This isn't really a bug, but a change request.

When invoking top with a very high number as refresh screen interval (s) from the command line, top uses 0 as the interval.

$ top -s 999999999

while displaying, you can exit with CTRL-C but you can't send new commands like a new time interval, or sort order (o) nor quit (q).

I would like to see an immediate exit, when invoked with invalid values, like in FreeBSD.

>How-To-Repeat:
$ top -s 999999999
>Fix:

>Audit-Trail:
From: Christopher Berardi <cberardi@natoufa.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/31908
Date: Sat, 20 Feb 2010 17:32:31 -0500

 This bug seems to be caused by the return result from strtod(3), which man indicates should return HUGE_VAL in cases of overflow. So this patch should resolve the issue.



 --- top.c.orig	2010-02-20 17:15:33.000000000 -0500
 +++ top.c	2010-02-20 17:16:28.000000000 -0500
 @@ -43,6 +43,7 @@
  #include <signal.h>
  #include <setjmp.h>
  #include <ctype.h>
 +#include <math.h>
  #include <sys/types.h>
  #include <sys/uio.h>
  #include <unistd.h>
 @@ -395,7 +396,7 @@

  	case 's':
  	    f = atof(optarg);
 -	    if (f < 0 || (f == 0 && getuid() != 0))
 +	    if (f < 0 || (f == 0 && getuid() != 0) || (f == HUGE_VAL))
  	    {
  		message_error(" Bad seconds delay");
  	    }



 -- 
 Christopher Berardi
 http://www.natoufa.com/

 Be still, and know that I am God (Psalms 46:10)

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: Christopher Berardi <cberardi@natoufa.com>
Subject: Re: bin/31908
Date: Sat, 20 Feb 2010 23:52:29 +0000

 On Sat, Feb 20, 2010 at 10:35:02PM +0000, Christopher Berardi wrote:
  >   	case 's':
  >   	    f = atof(optarg);
  >  -	    if (f < 0 || (f == 0 && getuid() != 0))
  >  +	    if (f < 0 || (f == 0 && getuid() != 0) || (f == HUGE_VAL))

 Better to use strtod() with proper error checking... plus this also
 wants an isnan() test.

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.