wxMaxima
Loading...
Searching...
No Matches
test
fuzz
fuzz_init.h
1
// Shared helper for the fuzz harnesses.
2
//
3
// wxGTK routes font/DC work through GTK, which needs an X display. Locally we run
4
// the fuzzers under `xvfb-run` (so DISPLAY is already set). In a headless
5
// environment such as OSS-Fuzz there is no display, so we start our own Xvfb
6
// once during initialization. No-op when a display is already available.
7
#ifndef WXM_FUZZ_INIT_H
8
#define WXM_FUZZ_INIT_H
9
10
#include <cstdlib>
11
#include <unistd.h>
12
13
static
inline
void
EnsureDisplay() {
14
// Only checks whether these are set, never uses their value.
15
if
(getenv(
"DISPLAY"
) || getenv(
"WAYLAND_DISPLAY"
))
// flawfinder: ignore
16
return
;
17
// Best-effort: requires Xvfb to be installed (the OSS-Fuzz Dockerfile does).
18
// Fixed literal command, no external input reaches it, and this only ever
19
// runs inside the fuzzer's own sandboxed harness.
20
if
(system(
"Xvfb :99 -screen 0 1280x1024x24 >/dev/null 2>&1 &"
) == 0) {
// flawfinder: ignore
21
setenv(
"DISPLAY"
,
":99"
, 1);
22
sleep(1);
// let Xvfb come up before GTK connects
23
}
24
}
25
26
#endif
Generated by
1.9.6