Bug 174856 - time(2) does not properly report errors
time(2) does not properly report errors
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
4
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-12-02 15:52 EST by William Kucharski
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 2.3.90-20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-12-21 09:33:27 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 1952 None None None Never

  None (edit)
Description William Kucharski 2005-12-02 15:52:10 EST
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 09:33:27 EST
Fixed in 2.3.90-20.

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