Skip to content

Commit

Permalink
a separate fuzzer for each codec
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Mar 7, 2024
1 parent c23c1ac commit 960a9d7
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 26 deletions.
20 changes: 20 additions & 0 deletions worker/fuzzer/include/RTC/Codecs/FuzzerH264.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef MS_FUZZER_RTC_CODECS_H264_HPP
#define MS_FUZZER_RTC_CODECS_H264_HPP

#include "common.hpp"

namespace Fuzzer
{
namespace RTC
{
namespace Codecs
{
namespace H264
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace Codecs
} // namespace RTC
} // namespace Fuzzer

#endif
20 changes: 20 additions & 0 deletions worker/fuzzer/include/RTC/Codecs/FuzzerH264_SVC.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef MS_FUZZER_RTC_CODECS_H264_SVC_HPP
#define MS_FUZZER_RTC_CODECS_H264_SVC_HPP

#include "common.hpp"

namespace Fuzzer
{
namespace RTC
{
namespace Codecs
{
namespace H264_SVC
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace Codecs
} // namespace RTC
} // namespace Fuzzer

#endif
20 changes: 20 additions & 0 deletions worker/fuzzer/include/RTC/Codecs/FuzzerOpus.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef MS_FUZZER_RTC_CODECS_OPUS_HPP
#define MS_FUZZER_RTC_CODECS_OPUS_HPP

#include "common.hpp"

namespace Fuzzer
{
namespace RTC
{
namespace Codecs
{
namespace Opus
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace Codecs
} // namespace RTC
} // namespace Fuzzer

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MS_FUZZER_RTC_CODECS_HPP
#define MS_FUZZER_RTC_CODECS_HPP
#ifndef MS_FUZZER_RTC_CODECS_VP8_HPP
#define MS_FUZZER_RTC_CODECS_VP8_HPP

#include "common.hpp"

Expand All @@ -9,7 +9,10 @@ namespace Fuzzer
{
namespace Codecs
{
void Fuzz(const uint8_t* data, size_t len);
namespace VP8
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace Codecs
} // namespace RTC
} // namespace Fuzzer
Expand Down
20 changes: 20 additions & 0 deletions worker/fuzzer/include/RTC/Codecs/FuzzerVP9.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef MS_FUZZER_RTC_CODECS_VP9_HPP
#define MS_FUZZER_RTC_CODECS_VP9_HPP

#include "common.hpp"

namespace Fuzzer
{
namespace RTC
{
namespace Codecs
{
namespace VP9
{
void Fuzz(const uint8_t* data, size_t len);
}
} // namespace Codecs
} // namespace RTC
} // namespace Fuzzer

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
88t

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

15 changes: 0 additions & 15 deletions worker/fuzzer/src/RTC/Codecs/FuzzerCodecs.cpp

This file was deleted.

14 changes: 14 additions & 0 deletions worker/fuzzer/src/RTC/Codecs/FuzzerH264.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "RTC/Codecs/FuzzerH264.hpp"
#include "RTC/Codecs/H264.hpp"

void Fuzzer::RTC::Codecs::H264::Fuzz(const uint8_t* data, size_t len)
{
::RTC::Codecs::H264::PayloadDescriptor* descriptor = ::RTC::Codecs::H264::Parse(data, len);

if (!descriptor)
{
return;
}

delete descriptor;
}
14 changes: 14 additions & 0 deletions worker/fuzzer/src/RTC/Codecs/FuzzerH264_SVC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "RTC/Codecs/FuzzerH264_SVC.hpp"
#include "RTC/Codecs/H264_SVC.hpp"

void Fuzzer::RTC::Codecs::H264_SVC::Fuzz(const uint8_t* data, size_t len)
{
::RTC::Codecs::H264_SVC::PayloadDescriptor* descriptor = ::RTC::Codecs::H264_SVC::Parse(data, len);

if (!descriptor)
{
return;
}

delete descriptor;
}
14 changes: 14 additions & 0 deletions worker/fuzzer/src/RTC/Codecs/FuzzerOpus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "RTC/Codecs/FuzzerOpus.hpp"
#include "RTC/Codecs/Opus.hpp"

void Fuzzer::RTC::Codecs::Opus::Fuzz(const uint8_t* data, size_t len)
{
::RTC::Codecs::Opus::PayloadDescriptor* descriptor = ::RTC::Codecs::Opus::Parse(data, len);

if (!descriptor)
{
return;
}

delete descriptor;
}
14 changes: 14 additions & 0 deletions worker/fuzzer/src/RTC/Codecs/FuzzerVP8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "RTC/Codecs/FuzzerVP8.hpp"
#include "RTC/Codecs/VP8.hpp"

void Fuzzer::RTC::Codecs::VP8::Fuzz(const uint8_t* data, size_t len)
{
::RTC::Codecs::VP8::PayloadDescriptor* descriptor = ::RTC::Codecs::VP8::Parse(data, len);

if (!descriptor)
{
return;
}

delete descriptor;
}
14 changes: 14 additions & 0 deletions worker/fuzzer/src/RTC/Codecs/FuzzerVP9.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "RTC/Codecs/FuzzerVP9.hpp"
#include "RTC/Codecs/VP9.hpp"

void Fuzzer::RTC::Codecs::VP9::Fuzz(const uint8_t* data, size_t len)
{
::RTC::Codecs::VP9::PayloadDescriptor* descriptor = ::RTC::Codecs::VP9::Parse(data, len);

if (!descriptor)
{
return;
}

delete descriptor;
}
14 changes: 11 additions & 3 deletions worker/fuzzer/src/fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include "LogLevel.hpp"
#include "Settings.hpp"
#include "Utils.hpp"
#include "RTC/Codecs/FuzzerCodecs.hpp"
#include "RTC/Codecs/FuzzerH264.hpp"
#include "RTC/Codecs/FuzzerH264_SVC.hpp"
#include "RTC/Codecs/FuzzerOpus.hpp"
#include "RTC/Codecs/FuzzerVP8.hpp"
#include "RTC/Codecs/FuzzerVP9.hpp"
#include "RTC/DtlsTransport.hpp"
#include "RTC/FuzzerDtlsTransport.hpp"
#include "RTC/FuzzerRtpPacket.hpp"
Expand Down Expand Up @@ -66,7 +70,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)

if (fuzzCodecs)
{
Fuzzer::RTC::Codecs::Fuzz(data, len);
Fuzzer::RTC::Codecs::Opus::Fuzz(data, len);
Fuzzer::RTC::Codecs::VP8::Fuzz(data, len);
Fuzzer::RTC::Codecs::VP9::Fuzz(data, len);
Fuzzer::RTC::Codecs::H264::Fuzz(data, len);
Fuzzer::RTC::Codecs::H264_SVC::Fuzz(data, len);
}

if (fuzzUtils)
Expand Down Expand Up @@ -137,7 +145,7 @@ int Init()

fuzzUtils = true;
}
if (!fuzzStun && !fuzzDtls && !fuzzRtcp && !fuzzRtp && !fuzzUtils)
if (!fuzzStun && !fuzzDtls && !fuzzRtp && !fuzzRtcp && !fuzzCodecs && !fuzzUtils)
{
std::cout << "[fuzzer] all fuzzers enabled" << std::endl;

Expand Down
6 changes: 5 additions & 1 deletion worker/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ executable(
'fuzzer/src/RTC/FuzzerSeqManager.cpp',
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
'fuzzer/src/RTC/Codecs/FuzzerCodecs.cpp',
'fuzzer/src/RTC/Codecs/FuzzerOpus.cpp',
'fuzzer/src/RTC/Codecs/FuzzerVP8.cpp',
'fuzzer/src/RTC/Codecs/FuzzerVP9.cpp',
'fuzzer/src/RTC/Codecs/FuzzerH264.cpp',
'fuzzer/src/RTC/Codecs/FuzzerH264_SVC.cpp',
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPs.cpp',
'fuzzer/src/RTC/RTCP/FuzzerFeedbackPsAfb.cpp',
Expand Down

0 comments on commit 960a9d7

Please sign in to comment.