Possible truncation of the cookie in telldir/seekdir.
Florian Weimer
fweimer@redhat.com
Fri Aug 30 11:38:00 GMT 2019
* Marcin Mielniczuk:
> On 32-bit OSes readdir64 will internally call the getdents64. There the
> value for dirent64::d_off will be taken from unsigned long
> linux_dirent::d_off, which is off64_t (the same as int64_t) and assigned
> to __dirstream::filepos, which is off_t. On 32-bit systems, off_t is the
> same as int32_t and long. Therefore, telldir will return a truncated
> value. This can be reproduced, for instance, when cross-compiling to
> arm-unknown-linux-gnueabi.
>
> This means that (1) the value returned in dirent64::d_off may not match
> the one returned by telldir (2) if we use seekdir with the value from
> dirent64::d_off, a silent lossy conversion may happen and the stream may
> be incorrectly seeked. According to POSIX, telldir & seekdir should use
> a long, so this can't be fixed by simply using off64_t everywhere.
Correct. It's a known issue.
<https://sourceware.org/bugzilla/show_bug.cgi?id=23960>
We know how to fix it, by allocating sufficiently small cookie values in
userspace. But we haven't implemented that yet.
> Btw. on my system there's no manpage describing readdir64. Is this intended?
No, it's something that needs to be fixed by the linux-man project.
Thanks,
Florian
More information about the Libc-help
mailing list