Skip to content

[libfuzzer] No Large File Support in 32bit targets #91130

Open
@ernst-schwaiger

Description

@ernst-schwaiger

FuzzerIOPosix.cpp hasn't enabled Large File Support/LFS for 32bit targets. All stat() invocations return EOVERFLOW on large file systems. Consequently, IsFile(), IsDirectory(), FileSize() will always return false/zero and e.g. my32BitFuzzBinary CORPUS stops with "ERROR: The required directory "CORPUS" does not exist"

Patching FuzzerIOPosix.cpp like this overcomes the issue (albeit adding -D_FILE_OFFSET_BITS=64 to the CMakefiles is a cleaner solution):

//...
#if (LIBFUZZER_POSIX || LIBFUZZER_FUCHSIA)

// turn LFS on for i386 (and other supported 32 bit platforms)
#if __i386
  #define _FILE_OFFSET_BITS 64
#endif

#include "FuzzerExtFunctions.h"
#include "FuzzerIO.h"
#include <cstdarg>
#include <cstdio>
#include <dirent.h>
#include <fstream>
#include <iterator>
#include <libgen.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

// ensure LFS is turned on
static_assert(sizeof(off_t) == 8, "Large file interface is not present, see _FILE_OFFSET_BITS in https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html");

namespace fuzzer {
//...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @EugeneZelenko@ernst-schwaiger

        Issue actions

          [libfuzzer] No Large File Support in 32bit targets · Issue #91130 · llvm/llvm-project