]> git.ipfire.org Git - thirdparty/kmod.git/commit
testsuite: fix override of `stat` on 32-bit architectures
authorJulien Cristau <jcristau@debian.org>
Mon, 5 Sep 2022 08:32:12 +0000 (10:32 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 5 Sep 2022 20:35:09 +0000 (13:35 -0700)
commitb4d281f962be74adfbae9d7bead6a7352033342c
treee0738abdc5cd11f7a27572c4c2d402fad42c51b8
parentc1fb98a30dae051ab69d23624d1e062d0527527e
testsuite: fix override of `stat` on 32-bit architectures

When _FILE_OFFSET_BITS is 64, glibc headers turn `stat` calls into
`stat64`, and our `stat` override into a `stat64` function.  However,
because we use dlsym to get the address of libc's `stat`, we end up
calling into the "real" `stat` function, which deals with 32-bit off_t,
and we treat its result as if it were returned from stat64.  On most
architectures this seems to have been harmless, but on 32-bit mips,
st_mode's offset in struct stat and struct stat64 are different, so we
read garbage.

To fix this, explicitly unset _FILE_OFFSET_BITS in path.c, to turn off
the redirect magic in glibc headers, and override both the 32-bit and
64-bit functions so each call ends up wrapping the right libc function.

Fixes #16 (https://github.com/kmod-project/kmod/issues/16)
testsuite/path.c