Code Monkey home page Code Monkey logo

Comments (7)

jmdavis avatar jmdavis commented on September 27, 2024

This will be released in 0.3.2.

from dxml.

JohanEngelen avatar JohanEngelen commented on September 27, 2024

@jmdavis [0x3c,0x3f] still crashes!

from dxml.

jmdavis avatar jmdavis commented on September 27, 2024

@jmdavis [0x3c,0x3f] still crashes!

Drat. I read through the issue too quickly and missed that there were two failing test cases. I'll fix it during the hackathon then.

from dxml.

jmdavis avatar jmdavis commented on September 27, 2024

Okay. That second case should also be fixed now.

from dxml.

JohanEngelen avatar JohanEngelen commented on September 27, 2024

That second case should also be fixed now.

Starting the fuzzer again! ;-)

from dxml.

JohanEngelen avatar JohanEngelen commented on September 27, 2024

New crash:
[0x3c,0x4d,0x3e,0x9,0x3b,0x3c,0x2f]

from dxml.

JohanEngelen avatar JohanEngelen commented on September 27, 2024

Fuzz target that should work with 1.8.0

// RUN: ~/ldc/ldc2-1.8.0-osx-x86_64/bin/ldc2 -g -fsanitize=fuzzer fuzz_dxml.d dxml/*.d

import std.typecons : Flag, Yes;


mixin template DefineTestOneInput(alias FuzzTarget, Flag!"initializeDRuntime" initializeDRuntime = Yes.initializeDRuntime)
    if (is(typeof(&FuzzTarget) == int function(in ubyte[])))
{
    static if (initializeDRuntime)
    {
        // Do druntime initialization and de-initialization through module ctor/dtor.
        // Choose a low priority = 10, to hopefully init before (de-init after) standard D module ctors (dtors).
        __gshared static bool runtimeInitialized = false;
        pragma(crt_constructor, 10)
        void initDRuntime()
        {
            import core.runtime : rt_init;
            rt_init();
            runtimeInitialized = true;
        }

        pragma(crt_destructor, 10)
        void terminateDRuntime()
        {
            import core.runtime : rt_term;
            if (runtimeInitialized)
                runtimeInitialized = !rt_term();
        }
    }

    // libFuzzer's user entry point
    pragma(mangle, "LLVMFuzzerTestOneInput") // Work around https://issues.dlang.org/show_bug.cgi?id=12575
    extern (C) int LLVMFuzzerTestOneInput(const(ubyte*) data, size_t size)
    {
        try
        {
            // Call the user's function
            return FuzzTarget(data[0 .. size]);
        }
        catch (Throwable t)
        {
            _d_print_throwable(t);
        }
        // We only reach here when an exception was caught.
        assert(0);
    }

    pragma(mangle, "_d_print_throwable") // Work around https://issues.dlang.org/show_bug.cgi?id=12575
    extern (C) void _d_print_throwable(Throwable t);
}

mixin DefineTestOneInput!fuzzMe;

int fuzzMe(in ubyte[] data)
{
    import dxml.parser;
    try
    {
        int sum;
        auto range = parseXML(cast(char[])data);
        foreach (elem; range) {
            // Do something unpredictable to actually test the parser
            sum += cast(int) elem.type;
        }
        return sum > 1;
    }
    catch (XMLParsingException)
    {
        return 0;
    }
}

from dxml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.