[Pkg-haskell-maintainers] Bug#773821: getPathVar fails to use statfs64() on i386 and can overflow

Joey Hess id at joeyh.name
Tue Dec 23 16:58:38 UTC 2014


Package: ghc
Version: 7.6.3-20
Severity: normal

import System.Posix.Files
import Control.Exception
import Foreign.C.Types
main = print =<< (try (getPathVar "." FileNameLimit) :: IO (Either IOException CLong))

This program can fail on a system with a large disk:

Left .: getPathVar: failed (Value too large for defined data type)

statfs(".", 0xffa8ad50)                 = -1 EOVERFLOW (Value too large for defined data type)

The problem is, getPathVar is using statfs, not statfs64.

Here's a C program that uses statfs64:

#define _LARGEFILE64_SOURCE 1
#include <sys/vfs.h>
#include <stdio.h>

main () {
        struct statfs64 buf;
        statfs64(".", &buf);
        printf("%li\n", buf.f_namelen);
}

And strace shows just how large some of the fields are, which is why
statfs() overflows.

statfs64(".", 84, {f_type=0x2fc12fc1, f_bsize=131072, f_blocks=67107265, f_bfree=66904371, f_bavail=66904371, f_files=17127878964, f_ffree=17127519173, f_fsid={-676822403, 15770009}, f_namelen=255, f_frsize=131072, f_flags=4128}) = 0

An added problem is that getPathVar is implemented using pathconf,
rather than using statfs directly. It seems that setting _LARGEFILE64_SOURCE
does not cause pathconf to use statfs64. This may be a glibc bug.

-- 
see shy jo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-haskell-maintainers/attachments/20141223/0c6a3c4a/attachment.sig>


More information about the Pkg-haskell-maintainers mailing list