xref: /freebsd/contrib/pkgconf/fuzzer/alloc-inject.h (revision 592efe252472a3385acf36b1f49ecf710a7f3d9c)
1 /*
2  * alloc-inject.h
3  * allocator fault injection for fuzzing harnesses
4  *
5  * SPDX-License-Identifier: pkgconf
6  *
7  * Copyright (c) 2026 pkgconf authors (see AUTHORS).
8  *
9  * Permission to use, copy, modify, and/or distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * This software is provided 'as is' and without any warranty, express or
14  * implied.  In no event shall the authors be liable for any damages arising
15  * from the use of this software.
16  */
17 
18 #ifndef PKGCONF_FUZZER_ALLOC_INJECT_H
19 #define PKGCONF_FUZZER_ALLOC_INJECT_H
20 
21 #include <stdbool.h>
22 
23 /* arm injection so that the fail_at-th allocation made while armed fails */
24 void alloc_inject_arm(unsigned long fail_at);
25 
26 /* stop failing allocations */
27 void alloc_inject_disarm(void);
28 
29 /* whether the armed failure point was actually reached since the last arm */
30 bool alloc_inject_fired(void);
31 
32 #endif
33