Bug 174856 - time(2) does not properly report errors
Summary: time(2) does not properly report errors
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 4
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-12-02 20:52 UTC by William Kucharski
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version: 2.3.90-20
Clone Of:
Environment:
Last Closed: 2005-12-21 14:33:27 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Sourceware 1952 0 None None None Never

Description William Kucharski 2005-12-02 20:52:10 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 Firefox/1.0.7

Description of problem:
If a bad buffer address is passed to time(2), rather than return (time_t)-1 and set errno to EFAULT, "-EFAULT" (-14) is returned directly to the caller.

Version-Release number of selected component (if applicable):
glibc-2.3.5-10.3

How reproducible:
Always

Steps to Reproduce:
1. Compile the following program:

#include <sys/types.h>
#include <time.h>
#include <stdio.h>

main()
{
    time_t tick;
    
    tick = time((time_t *)1);

    if (tick == (time_t)-1)
            perror("time");
    else
            printf("time() returned %d: %s", tick, ctime(&tick));

}

2. Run the program
  

Actual Results:  time() returned -14: Wed Dec 31 16:59:46 1969


Expected Results:  time: Bad address


Additional info:

This appears to be a long-standing bug in glibc where it apparently is not doing its normal "a negative return value from a syscall means a a failure with errno -return_value" processing, likely due to the fact that large negative values may be returned from the time syscall as time speeds away from the epoch.

Comment 1 Jakub Jelinek 2005-12-21 14:33:27 UTC
Fixed in 2.3.90-20.


Note You need to log in before you can comment on or make changes to this bug.