From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23107 invoked by alias); 30 Nov 2005 16:31:26 -0000 Received: (qmail 23100 invoked by alias); 30 Nov 2005 16:31:25 -0000 Date: Wed, 30 Nov 2005 16:31:00 -0000 Message-ID: <20051130163125.23099.qmail@sourceware.org> From: "michael dot kerrisk at gmx dot net" To: glibc-bugs@sources.redhat.com In-Reply-To: <20051130155046.1952.michael.kerrisk@gmx.net> References: <20051130155046.1952.michael.kerrisk@gmx.net> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/1952] time() returns incorrect value when given bad address X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00142.txt.bz2 List-Id: ------- 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. Hi Jakub Thanks for your quick reply. POSIX does not define any errno values for time(), but nevertheless says: 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 here. 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). Cheers, Michael -- http://sourceware.org/bugzilla/show_bug.cgi?id=1952 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.