This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/1952] New: 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 15:50:46 -0000
- Subject: [Bug libc/1952] New: time() returns incorrect value when given bad address
- Reply-to: sourceware-bugzilla at sourceware dot org
When the program below is run on Linux/x86, the following output
is produced:
After time(): t=-14, errno=0
After syscall(SYS_time): t=-1, errno=14
In the first line, the reported return value from time() should be
-1, with errno set to EFAULT (14). Instead, the call returns -14.
Could this be a configuration problem in
sysdeps/unix/sysv/linux/i386/syscalls.list?
Cheers,
Michael
==========
#define _GNU_SOURCE
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <time.h>
#define VAL 1000
int main() {
time_t t;
t = time((time_t *)VAL);
printf("After time(): t=%ld, errno=%d\n", (long) t, errno);
t = syscall(SYS_time, (time_t *)VAL);
printf("After syscall(SYS_time): t=%ld, errno=%d\n", (long) t, errno);
return 0;
}
--
Summary: time() returns incorrect value when given bad address
Product: glibc
Version: 2.3.5
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: michael dot kerrisk at gmx dot net
CC: glibc-bugs at sources dot redhat dot com
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.