Subject: lib/15265: fsetpos() silently truncates file offsets to "long"
To: None <email@example.com>
From: None <M.Drochner@fz-juelich.de>
Date: 01/16/2002 18:47:53
>Synopsis: fsetpos() silently truncates file offsets to "long"
>Arrival-Date: Wed Jan 16 09:49:00 PST 2002
>Originator: Matthias Drochner
>Release: NetBSD 1.5
System: NetBSD zelz26 1.5ZA NetBSD 1.5ZA (ZELZ26) #134: Wed Jan 9 19:36:59 MET 2002 drochner@zelz26:/home/drochner/netbsd/sys/arch/i386/compile/ZELZ26 i386
The c library function fsetpos() gets passed an fpos_t as file
offset (which is defined as off_t), ie 64 bit.
It is implemented as a call to fseek(), passing a "long" as file offset
which means that it gets truncated on 32-bit platforms.
The following test code fails on NetBSD-1.5/i386 but succeeds on -current:
a = fopen("mist", "w");
b = 0x80000001;
res = fsetpos(a, &b);
In -current, fsetpos() uses fseeko(), which is identical to fseek()
except the "long" replaced by "off_t".