tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

stun_parser_libfuzz.cpp (926B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "FuzzingInterface.h"
      8 #include "gtest/gtest.h"
      9 
     10 extern "C" {
     11 #include <csi_platform.h>
     12 
     13 #include "stun_codec.h"
     14 #include "stun_msg.h"
     15 }
     16 
     17 int FuzzingInitStunParser(int* argc, char*** argv) { return 0; }
     18 
     19 static int RunStunParserFuzzing(const uint8_t* data, size_t size) {
     20  nr_stun_message* req = 0;
     21 
     22  UCHAR* mes = (UCHAR*)data;
     23 
     24  if (!nr_stun_message_create2(&req, mes, size)) {
     25    nr_stun_decode_message(req, nullptr, nullptr);
     26    nr_stun_message_destroy(&req);
     27  }
     28 
     29  return 0;
     30 }
     31 
     32 MOZ_FUZZING_INTERFACE_RAW(FuzzingInitStunParser, RunStunParserFuzzing,
     33                          StunParser);