{"id":16880749,"url":"https://github.com/wtdcode/libfuzzer","last_synced_at":"2025-03-20T03:34:20.962Z","repository":{"id":57438650,"uuid":"450301349","full_name":"wtdcode/libfuzzer","owner":"wtdcode","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-22T01:08:55.000Z","size":2006,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-25T12:46:52.771Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wtdcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-21T00:25:10.000Z","updated_at":"2023-10-18T08:41:14.000Z","dependencies_parsed_at":"2022-09-08T07:10:26.715Z","dependency_job_id":null,"html_url":"https://github.com/wtdcode/libfuzzer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Flibfuzzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Flibfuzzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Flibfuzzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wtdcode%2Flibfuzzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wtdcode","download_url":"https://codeload.github.com/wtdcode/libfuzzer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244544437,"owners_count":20469684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T15:59:57.937Z","updated_at":"2025-03-20T03:34:20.945Z","avatar_url":"https://github.com/wtdcode.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libfuzzer\n\nThis is modified version of libfuzzer.\n\n## API\n\n```C\n// Mandatory user-provided target function.\n// Executes the code under test with [Data, Data+Size) as the input.\n// libFuzzer will invoke this function *many* times with different inputs.\n// Must return 0.\ntypedef int (*TestOneInputCallback)(const uint8_t *Data, size_t Size);\n\n// Optional user-provided initialization function.\n// If provided, this function will be called by libFuzzer once at startup.\n// It may read and modify argc/argv.\n// Must return 0.\ntypedef int (*InitializeCallback)(int *argc, char ***argv);\n\n// Optional user-provided custom mutator.\n// Mutates raw data in [Data, Data+Size) inplace.\n// Returns the new size, which is not greater than MaxSize.\n// Given the same Seed produces the same mutation.\ntypedef size_t (*CustomMutatorCallback)(uint8_t *Data, size_t Size,\n                                        size_t MaxSize, unsigned int Seed);\n\n// Optional user-provided custom cross-over function.\n// Combines pieces of Data1 \u0026 Data2 together into Out.\n// Returns the new size, which is not greater than MaxOutSize.\n// Should produce the same mutation given the same Seed.\ntypedef size_t (*CustomCrossOverCallback)(const uint8_t *Data1, size_t Size1,\n                                          const uint8_t *Data2, size_t Size2,\n                                          uint8_t *Out, size_t MaxOutSize,\n                                          unsigned int Seed);\n\n// Experimental, may go away in future.\n// libFuzzer-provided function to be used inside LLVMFuzzerCustomMutator.\n// Mutates raw data in [Data, Data+Size) inplace.\n// Returns the new size, which is not greater than MaxSize.\nFUZZER_INTERFACE_VISIBILITY size_t\nLLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize);\n\n// The main entry of the fuzzer.\nFUZZER_INTERFACE_VISIBILITY int\nLLVMFuzzerRunDriver(int *argc, char ***argv, TestOneInputCallback UserCb,\n                    InitializeCallback InitCb, CustomMutatorCallback MutCb,\n                    CustomCrossOverCallback CrossCb, uint8_t *Counters,\n                    size_t CountersSize);\n```\n\nWith a little hack, this version of libfuzzer exposes the extra counters defined in `FuzzerExtraCounters.cpp`, which make it esay to use libfuzzer as a library.\n\n## Example\n\n```C\n#include \"LibFuzzer.h\"\n#include \u003cstdio.h\u003e\n\nstatic uint8_t Counters[4096];\n\nint Test(const uint8_t *p, size_t s) {\n  // Instrument the code manually.\n  if (s == 0) {\n    Counters[0]++;\n  } else if (s == 8) {\n    Counters[1]++;\n  } else if (s == 16) {\n    Counters[2]++;\n    abort();\n  } else {\n    Counters[3]++;\n  }\n  Counters[4]++;\n  return 0;\n}\n\nint Init(int *argc, char ***argv) { printf(\"Initialized!\\n\"); }\n\nsize_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed) {\n  return LLVMFuzzerMutate(Data, Size, MaxSize);\n}\n\nsize_t CrossOver(const uint8_t *Data1, size_t Size1, const uint8_t *Data2,\n                 size_t Size2, uint8_t *Out, size_t MaxOutSize,\n                 unsigned int Seed) {\n  return 0; // Do nothing\n}\n\nint main(int argc, char **argv) {\n  LLVMFuzzerRunDriver(\u0026argc, \u0026argv, Test, Init, Mutate, CrossOver,\n                      (uint8_t *)Counters, 4096);\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtdcode%2Flibfuzzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwtdcode%2Flibfuzzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwtdcode%2Flibfuzzer/lists"}