Subject: lib/8657: alarm(3) accepts more seconds than it can handle.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <z@rentaboat.se>
List: netbsd-bugs
Date: 10/20/1999 12:55:43
>Number:         8657
>Category:       lib
>Synopsis:       alarm(3) accepts more seconds than it can handle.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 20 12:54:00 1999
>Last-Modified:
>Originator:     Zs
>Organization:
>Release:        NetBSD-1.4/mac68k
>Environment:
NetBSD anon.host 1.4 NetBSD 1.4 (KERN) #0: Tue Sep 14 09:14:55 PDT 1999
    z@anon.host:/usr/src/sys/arch/i386/compile/KERN i386

>Description:

The man page alarm(3) says that the seconds argument can have a
maximum value of 2147483647, but the function calls setitimer(2),
which accepts a maximum of 100000000 seconds.
>How-To-Repeat:

#include <stdio.h>
#include <unistd.h>

int
main(void)
{
	unsigned at;

	alarm(100000001);
	at = alarm(0);
	(void) printf("Time left: %u\n", at);

	return 0;
}
>Fix:

I see two possible solutions for this:

1) In lib/libc/gen/alarm.c, put a check for the value:

	if (secs > 100000000)
		return (unsigned) -1;

   Update the man page to this limit.

2) Just increase the limit in sys/kern/kern_time.c.
>Audit-Trail:
>Unformatted: