curl-fuzzer C++ reference
Loading...
Searching...
No Matches
bounded_anonymous_input_file.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3 *
4 * SPDX-License-Identifier: curl
5 */
6
9
10#ifndef PROTO_FUZZER_BOUNDED_ANONYMOUS_INPUT_FILE_H_
11#define PROTO_FUZZER_BOUNDED_ANONYMOUS_INPUT_FILE_H_
12
13#include <cstddef>
14#include <cstdint>
15#include <cstdio>
16#include <string>
17
18namespace proto_fuzzer {
19
25 public:
26 explicit BoundedAnonymousInputFile(std::size_t max_bytes);
27
29
31 BoundedAnonymousInputFile& operator=(const BoundedAnonymousInputFile&) = delete;
32
33 bool Write(const std::uint8_t* data, std::size_t size);
34
35 const char* path() const;
36
37 private:
38 bool EnsureOpen();
39
40 std::size_t max_bytes_;
41 std::FILE* file_;
42 std::string path_;
43 bool ready_;
44};
45
46} // namespace proto_fuzzer
47
48#endif // PROTO_FUZZER_BOUNDED_ANONYMOUS_INPUT_FILE_H_
bool Write(const std::uint8_t *data, std::size_t size)
Replace the complete file contents with one bounded byte string.
~BoundedAnonymousInputFile()
Close the anonymous file, invalidating the procfs pathname.
BoundedAnonymousInputFile(std::size_t max_bytes)
Construct a lazy owner.
const char * path() const
Return the stable procfs pathname after a successful Write.