// A crash so we can tell the harness is working for lib_echo if(data[0] == 'p') { if(data[1] == 'o') { if(data[2] =='p') { if(data[3] == '!') { assert(0); } } } } }
// fixed size buffer based on assumptions about the maximum size that is likely necessary to exercise all aspects of the target function #define SIZE 50
intmain() { // make sure buffer is initialized to eliminate variable behaviour that isn't dependent on the input. char input[SIZE] = {0};
// fixed size buffer based on assumptions about the maximum size that is likely necessary to exercise all aspects of the target function #define SIZE 100
intmain(int argc, char* argv[]) { if((argc == 2) && strcmp(argv[1], "echo") == 0) { // make sure buffer is initialized to eliminate variable behaviour that isn't dependent on the input. char input[SIZE] = {0};
CC=afl-clang-fast ./autogen.sh # you could also use afl-clang-lto, which is usally the better choice, but - oddly - in this case it takes longer to find the bug with an lto build. AFL_USE_ASAN=1 make -j 4
// Copyright 2016 Google Inc. All Rights Reserved. // Licensed under the Apache License, Version 2.0 (the "License"); #include <openssl/ssl.h> #include <openssl/err.h> #include <assert.h> #include <stdint.h> #include <stddef.h> #include <unistd.h>
#ifndef CERT_PATH # define CERT_PATH #endif
SSL_CTX *Init() { SSL_library_init(); SSL_load_error_strings(); ERR_load_BIO_strings(); OpenSSL_add_all_algorithms(); SSL_CTX *sctx; assert (sctx = SSL_CTX_new(TLSv1_method())); /* These two file were created with this command: openssl req -x509 -newkey rsa:512 -keyout server.key \ -out server.pem -days 9999 -nodes -subj /CN=a/ */ assert(SSL_CTX_use_certificate_file(sctx, "server.pem", SSL_FILETYPE_PEM)); assert(SSL_CTX_use_PrivateKey_file(sctx, "server.key", SSL_FILETYPE_PEM)); return sctx; }
int main() { static SSL_CTX *sctx = Init(); SSL *server = SSL_new(sctx); BIO *sinbio = BIO_new(BIO_s_mem()); BIO *soutbio = BIO_new(BIO_s_mem()); SSL_set_bio(server, sinbio, soutbio); SSL_set_accept_state(server);
/* TODO: To spoof one end of the handshake, we need to write data to sinbio * here */ uint8_t data[100] = {0}; size_t size = read(STDIN_FILENO,data,100); if (size == -1){ printf("Failed to read from stdin \n"); return (-1); } BIO_write(sinbio, data, size);
CC=clang CFLAGS="--coverage -g -O0" ./configure && make -C ntpq cd .. for F in out/default/queue/id* ; do ./ntp-4.2.8p10/ntpq/ntpq < $F > /dev/null ; done cd ./ntp-4.2.8p10/ntpq/ && llvm-cov gcov ntpq.c