|
Packit Service |
084de1 |
/*
|
|
Packit Service |
084de1 |
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
|
Packit Service |
084de1 |
*
|
|
Packit Service |
084de1 |
* Licensed under the OpenSSL licenses, (the "License");
|
|
Packit Service |
084de1 |
* you may not use this file except in compliance with the License.
|
|
Packit Service |
084de1 |
* You may obtain a copy of the License at
|
|
Packit Service |
084de1 |
* https://www.openssl.org/source/license.html
|
|
Packit Service |
084de1 |
* or in the file LICENSE in the source distribution.
|
|
Packit Service |
084de1 |
*/
|
|
Packit Service |
084de1 |
#include <stdint.h>
|
|
Packit Service |
084de1 |
#include <unistd.h>
|
|
Packit Service |
084de1 |
#include <stdlib.h>
|
|
Packit Service |
084de1 |
#include <openssl/opensslconf.h>
|
|
Packit Service |
084de1 |
#include "fuzzer.h"
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#ifndef OPENSSL_NO_FUZZ_LIBFUZZER
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int LLVMFuzzerInitialize(int *argc, char ***argv);
|
|
Packit Service |
084de1 |
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len);
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
return FuzzerInitialize(argc, argv);
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
return FuzzerTestOneInput(buf, len);
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#elif !defined(OPENSSL_NO_FUZZ_AFL)
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#define BUF_SIZE 65536
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
int main(int argc, char** argv)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
FuzzerInitialize(&argc, &argv);
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
while (__AFL_LOOP(10000)) {
|
|
Packit Service |
084de1 |
uint8_t *buf = malloc(BUF_SIZE);
|
|
Packit Service |
084de1 |
size_t size = read(0, buf, BUF_SIZE);
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
FuzzerTestOneInput(buf, size);
|
|
Packit Service |
084de1 |
free(buf);
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
FuzzerCleanup();
|
|
Packit Service |
084de1 |
return 0;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#else
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#error "Unsupported fuzzer"
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
#endif
|