<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fuzzer crashed while fuzzing Mosquitto lib"
   href="https://bugs.llvm.org/show_bug.cgi?id=43435">43435</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fuzzer crashed while fuzzing Mosquitto lib
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>compiler-rt
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>fuzzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>huangyu.hw@foxmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi,
Here comes a bug while fuzzing Mosquitto lib, I would like to know the solution
or the group/person I can contact.

Step1. compile the lib

#:~/fuzz/fuzzmqtt/mosquitto$ ls
about.html       doc                   Makefile            security
aclfile.example  docker                man                 SECURITY.md
appveyor.yml     edl-v10               misc                service
buildtest.py     epl-v10               mosquitto.conf      set-version.sh
ChangeLog.txt    examples              Mosquitto.podspec   snap
client           installer             notice.html         src
CMakeLists.txt   lib                   pskfile.example     test
compiling.txt    libmosquitto.pc.in    pwfile.example      THANKS.txt
config.h         libmosquittopp.pc.in  readme.md           travis-configure.sh
config.mk        LICENSE.txt           readme-tests.md     travis-install.sh
CONTRIBUTING.md  logo                  readme-windows.txt  www


#:~/fuzz/fuzzmqtt/mosquitto$ sudo make install CC="clang -O2
-fno-omit-frame-pointer -g -fsanitize=address
-fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div" -j2

Step2. compile the fuzzer

#:~/fuzz/fuzzmqtt/mosquitto/lib$ clang -g -O1 -fsanitize=fuzzer,address
mos_fuzzer.cc -o mos_fuzzer -lmosquitto

Step3. Run the fuzzer and got the bug

#~/fuzz/fuzzmqtt/mosquitto/lib$ ./mos_fuzzer 
INFO: Seed: 106983829
INFO: Loaded 1 modules   (2337 guards): 2337 [0x7f157cd816b0, 0x7f157cd83b34), 
INFO: Loaded 1 modules   (1 inline 8-bit counters): 1 [0x787f80, 0x787f81), 
INFO: Loaded 1 PC tables (1 PCs): 1 [0x565af8,0x565b08), 
ERROR: The size of coverage PC tables does not match the
number of instrumented PCs. This might be a compiler bug,
please contact the libFuzzer developers.
Also check <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - make -fsanitize-coverage=pc-table friendly with -ffunction-sections -Wl,-gc-sections"
   href="show_bug.cgi?id=34636">https://bugs.llvm.org/show_bug.cgi?id=34636</a>
for possible workarounds (tl;dr: don't use the old GNU ld)

The fuzzer code is as follow


#include "stdio.h"
#include "mosquitto.h"
#include "assert.h"
#include "stdint.h"
#include "stddef.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

    bool clean_session = true;
    struct mosquitto *mosq = NULL;
    mosquitto_lib_init();
    void *data_1=(void *)data;
    mosq = mosquitto_new(NULL, clean_session, data_1);
    mosquitto_destroy(mosq);
    mosquitto_lib_cleanup();
    return 0;
}

Thank you</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>