robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 1 | /* |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 2 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 3 | * honggfuzz - reporting |
| 4 | * ----------------------------------------- |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 5 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 6 | * Author: Robert Swiecki <swiecki@google.com> |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 7 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 8 | * Copyright 2010-2015 by Google Inc. All Rights Reserved. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 9 | * |
| 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | * not use this file except in compliance with the License. You may obtain |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 12 | * a copy of the License at |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 13 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 15 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 16 | * Unless required by applicable law or agreed to in writing, software |
| 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 19 | * implied. See the License for the specific language governing |
| 20 | * permissions and limitations under the License. |
robert.swiecki@gmail.com | 3b630b4 | 2015-02-16 10:53:53 +0000 | [diff] [blame] | 21 | * |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
| 24 | #include "common.h" |
| 25 | #include "report.h" |
| 26 | |
robert.swiecki@gmail.com | 90e9911 | 2015-02-15 02:05:14 +0000 | [diff] [blame] | 27 | #include <fcntl.h> |
| 28 | #include <stdio.h> |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 29 | #include <sys/types.h> |
| 30 | #include <sys/stat.h> |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 31 | |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 32 | #include "log.h" |
robert.swiecki@gmail.com | 90e9911 | 2015-02-15 02:05:14 +0000 | [diff] [blame] | 33 | #include "util.h" |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 34 | |
| 35 | static int reportFD = -1; |
| 36 | |
Anestis Bechtsoudis | f5268a6 | 2015-08-07 16:48:46 +0300 | [diff] [blame] | 37 | #if defined(_HF_ARCH_LINUX) |
| 38 | static void report_printdynFileMethod(honggfuzz_t * hfuzz) |
| 39 | { |
| 40 | dprintf(reportFD, " dynFileMethod: "); |
| 41 | if (hfuzz->dynFileMethod == 0) |
| 42 | dprintf(reportFD, "NONE\n"); |
| 43 | else { |
| 44 | if (hfuzz->dynFileMethod & _HF_DYNFILE_INSTR_COUNT) |
| 45 | dprintf(reportFD, "INSTR_COUNT "); |
| 46 | if (hfuzz->dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) |
| 47 | dprintf(reportFD, "BRANCH_COUNT "); |
| 48 | if (hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_BLOCK_COUNT) |
| 49 | dprintf(reportFD, "BLOCK_COUNT "); |
| 50 | if (hfuzz->dynFileMethod & _HF_DYNFILE_UNIQUE_EDGE_COUNT) |
| 51 | dprintf(reportFD, "EDGE_COUNT "); |
| 52 | if (hfuzz->dynFileMethod & _HF_DYNFILE_CUSTOM) |
| 53 | dprintf(reportFD, "CUSTOM "); |
Anestis Bechtsoudis | f9f4a85 | 2015-08-18 14:30:02 +0300 | [diff] [blame^] | 54 | |
Anestis Bechtsoudis | f5268a6 | 2015-08-07 16:48:46 +0300 | [diff] [blame] | 55 | dprintf(reportFD, "\n"); |
| 56 | } |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | static void report_printTargetCmd(honggfuzz_t * hfuzz) |
| 61 | { |
| 62 | dprintf(reportFD, " fuzzTarget : "); |
| 63 | for (int x = 0; hfuzz->cmdline[x]; x++) { |
| 64 | dprintf(reportFD, "%s ", hfuzz->cmdline[x]); |
| 65 | } |
| 66 | dprintf(reportFD, "\n"); |
| 67 | } |
| 68 | |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 69 | void report_Report(honggfuzz_t * hfuzz, char *s) |
| 70 | { |
| 71 | if (s[0] == '\0') { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | if (reportFD == -1) { |
| 76 | reportFD = open(hfuzz->reportFile, O_WRONLY | O_CREAT | O_APPEND, 0644); |
| 77 | } |
| 78 | if (reportFD == -1) { |
| 79 | LOGMSG_P(l_FATAL, "Couldn't open('%s') for writing", hfuzz->reportFile); |
| 80 | } |
| 81 | |
robert.swiecki@gmail.com | 90e9911 | 2015-02-15 02:05:14 +0000 | [diff] [blame] | 82 | char localtmstr[PATH_MAX]; |
| 83 | util_getLocalTime("%F.%H:%M:%S", localtmstr, sizeof(localtmstr)); |
| 84 | |
| 85 | dprintf(reportFD, |
| 86 | "=====================================================================\n" |
| 87 | "TIME: %s\n" |
| 88 | "=====================================================================\n" |
Anestis Bechtsoudis | f5268a6 | 2015-08-07 16:48:46 +0300 | [diff] [blame] | 89 | "FUZZER ARGS:\n" |
| 90 | " flipRate : %lf\n" |
| 91 | " externalCmd : %s\n" |
| 92 | " fuzzStdin : %s\n" |
| 93 | " timeout : %ld (sec)\n" |
| 94 | " ignoreAddr : %p\n" |
| 95 | " memoryLimit : %lu (MiB)\n" |
| 96 | " targetPid : %d\n" |
| 97 | " wordlistFile : %s\n", |
| 98 | localtmstr, |
| 99 | hfuzz->flipRate, |
| 100 | hfuzz->externalCommand == NULL ? "NULL" : hfuzz->externalCommand, |
| 101 | hfuzz->fuzzStdin ? "TRUE" : "FALSE", |
| 102 | hfuzz->tmOut, |
| 103 | hfuzz->ignoreAddr, |
| 104 | hfuzz->asLimit, |
| 105 | hfuzz->pid, |
| 106 | hfuzz->dictionaryFile == NULL ? "NULL" : hfuzz->dictionaryFile); |
| 107 | |
| 108 | #if defined(_HF_ARCH_LINUX) |
| 109 | report_printdynFileMethod(hfuzz); |
| 110 | #endif |
| 111 | |
| 112 | report_printTargetCmd(hfuzz); |
| 113 | |
| 114 | dprintf(reportFD, |
robert.swiecki@gmail.com | bb5d264 | 2015-02-25 20:00:00 +0000 | [diff] [blame] | 115 | "%s" "=====================================================================\n", |
Anestis Bechtsoudis | f5268a6 | 2015-08-07 16:48:46 +0300 | [diff] [blame] | 116 | s); |
robert.swiecki@gmail.com | 97c7733 | 2015-02-14 23:06:58 +0000 | [diff] [blame] | 117 | |
| 118 | return; |
| 119 | } |