Subject: lib/8657: alarm(3) accepts more seconds than it can handle.
To: None <>
From: None <>
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
>Originator:     Zs
>Release:        NetBSD-1.4/mac68k
NetBSD 1.4 NetBSD 1.4 (KERN) #0: Tue Sep 14 09:14:55 PDT 1999 i386


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.

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

	unsigned at;

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

	return 0;

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.