提交 3f7c7f19 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

fuzzer: paying with fuzzer.cpp

上级 91b3fa4c
...@@ -91,7 +91,7 @@ Some environment variables than `fuzzer-run` are supported. However: ...@@ -91,7 +91,7 @@ Some environment variables than `fuzzer-run` are supported. However:
Example: Example:
```bash ```bash
$ FUZZER_CORPUS_DIRS="fuzzer/corpora/rtp-corpus" make fuzzer-docker-run $ FUZZER_OPTIONS="-max_len=1800" FUZZER_CORPUS_DIRS="fuzzer/corpora/stun-corpus fuzzer/corpora/rtp-corpus fuzzer/corpora/rtcp-corpus" make fuzzer-docker-run
``` ```
......
#include "DepLibUV.hpp" #include "DepLibUV.hpp"
#include "DepOpenSSL.hpp" #include "DepOpenSSL.hpp"
#include "Utils.hpp" #include "Utils.hpp"
#include "RTC/StunMessage.hpp"
#include "RTC/RtpPacket.hpp" #include "RTC/RtpPacket.hpp"
#include "RTC/RTCP/Packet.hpp"
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <iostream> #include <iostream>
using namespace RTC;
int init() int init()
{ {
// Initialize static stuff. // Initialize static stuff.
...@@ -22,13 +26,34 @@ void fuzz(const uint8_t* data, size_t len) ...@@ -22,13 +26,34 @@ void fuzz(const uint8_t* data, size_t len)
// If a RTP packet clone it, read properties, set stuff, etc. // If a RTP packet clone it, read properties, set stuff, etc.
// If RTCP the same. // If RTCP the same.
// If ICE too. // If ICE too.
//
// NOTE: This code could be split in different files under a new src/ folder
// with its corresponding new include/ folder.
// Check if it's STUN.
if (StunMessage::IsStun(data, len))
{
StunMessage* msg = StunMessage::Parse(data, len);
RTC::RtpPacket::IsRtp(data, len); if (msg)
delete msg;
}
// Check if it's RTCP.
else if (RTCP::Packet::IsRtcp(data, len))
{
RTCP::Packet* packet = RTCP::Packet::Parse(data, len);
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(data, len); if (packet)
delete packet;
}
// Check if it's RTP.
else if (RtpPacket::IsRtp(data, len))
{
RtpPacket* packet = RtpPacket::Parse(data, len);
if (packet) if (packet)
delete packet; delete packet;
}
} }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论