Red Hat Bugzilla – Bug 174856
time(2) does not properly report errors
Last modified: 2007-11-30 17:11:18 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):
Steps to Reproduce:
1. Compile the following program:
tick = time((time_t *)1);
if (tick == (time_t)-1)
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
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.
Fixed in 2.3.90-20.