contrib/fuzz/fuzzutil.h
author Sandu Turcan <idlsoft@gmail.com>
Tue, 03 May 2022 21:44:30 -0400
branchstable
changeset 49241 6b10151b9621
parent 43615 6f5c352f41b6
permissions -rw-r--r--
narrow_widen_acl: enforce narrowacl in narrow_widen (SEC) Reviewer note: this was sent by the author as a simple bugfix, but can be considered a security patch, since it allows users to access things outside of the ACL, hence the (SEC) prefix. However, this affects the `narrow` extention which is still marked as experimental and has relatively few users aside from large companies with their own security layers on top from what we can gather. We feel (Alphare: or at least, I feel) like pinging the packaging list is enough in this case.

#ifndef CONTRIB_FUZZ_FUZZUTIL_H
#define CONTRIB_FUZZ_FUZZUTIL_H
#include <iostream>
#include <memory>
#include <stdint.h>

/* Try and use std::optional, but failing that assume we'll have a
 * workable https://abseil.io/ install on the include path to get
 * their backport of std::optional. */
#ifdef __has_include
#if __has_include(<optional>) && __cplusplus >= 201703L
#include <optional>
#define CONTRIB_FUZZ_HAVE_STD_OPTIONAL
#endif
#endif
#ifdef CONTRIB_FUZZ_HAVE_STD_OPTIONAL
namespace contrib
{
using std::nullopt;
using std::optional;
} /* namespace contrib */
#else
#include "third_party/absl/types/optional.h"
namespace contrib
{
using absl::nullopt;
using absl::optional;
} /* namespace contrib */
#endif

/* set DEBUG to 1 for a few debugging prints, or 2 for a lot */
#define DEBUG 0
#define LOG(level)                                                             \
	if (level <= DEBUG)                                                    \
	std::cout

#endif /* CONTRIB_FUZZ_FUZZUTIL_H */