This is the mail archive of the
mailing list for the glibc project.
[Bug libc/1952] time() returns incorrect value when given bad address
- From: "michael dot kerrisk at gmx dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 30 Nov 2005 16:31:25 -0000
- Subject: [Bug libc/1952] time() returns incorrect value when given bad address
- References: <firstname.lastname@example.org>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From michael dot kerrisk at gmx dot net 2005-11-30 16:31 -------
Subject: Re: time() returns incorrect value when given bad address
> time is marked with E, i.e. not returning error (which I'd say matches
> POSIX which doesn't define any errors for time). By passing an invalid
> address to the function you reach undefined behaviour territory and all
> answers are fine in that case.
Thanks for your quick reply.
POSIX does not define any errno values for time(), but nevertheless
Upon successful completion, time( ) shall return the value of
time. Otherwise, (time_t)−1 shall be returned.
In my book, that means that time() should reasonably return -1
The POSIX.1 "No errors are defined" means
that error values returned by a function or stored into a
variable accessed through the symbol errno, if any, depend
on the implementation.
This does not (in my reading) mean that no error indication
(i.e., -1 in this case) should be returned.
Note also that glibc is thwarting the underlying system call, which
does actually return -1 for this case (as my program demonstrates).
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.