fuzzers: set fontconfig sysroot

Allows to specify custom fontconfig sysroot. Useful for fuzzing
environments where we might use specific config, font or the system wide
config is not available.
This commit is contained in:
Kacper Michajłow
2025-08-06 02:25:21 +02:00
parent 0232ff27a8
commit cc660f8609
5 changed files with 15 additions and 0 deletions

View File

@@ -48,6 +48,13 @@ static inline bool str_startswith(const char *str, size_t str_len,
return !memcmp(str, prefix, prefix_len); return !memcmp(str, prefix, prefix_len);
} }
static inline void set_fontconfig_sysroot(void)
{
#ifdef MPV_FONTCONFIG_SYSROOT
setenv("FONTCONFIG_SYSROOT", MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT), 1);
#endif
}
#ifndef PLAYBACK_TIME_LIMIT #ifndef PLAYBACK_TIME_LIMIT
#define PLAYBACK_TIME_LIMIT 5 #define PLAYBACK_TIME_LIMIT 5
#endif #endif

View File

@@ -64,6 +64,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (sprintf(filename, "fd://%d", fd) <= 5) if (sprintf(filename, "fd://%d", fd) <= 5)
exit(1); exit(1);
set_fontconfig_sysroot();
mpv_handle *ctx = mpv_create(); mpv_handle *ctx = mpv_create();
if (!ctx) if (!ctx)
exit(1); exit(1);

View File

@@ -39,6 +39,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
return 0; return 0;
#endif #endif
set_fontconfig_sysroot();
mpv_handle *ctx = mpv_create(); mpv_handle *ctx = mpv_create();
if (!ctx) if (!ctx)
exit(1); exit(1);

View File

@@ -56,6 +56,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
} }
opts[count] = NULL; opts[count] = NULL;
set_fontconfig_sysroot();
mpv_handle *ctx = mpv_create(); mpv_handle *ctx = mpv_create();
if (!ctx) if (!ctx)
exit(1); exit(1);

View File

@@ -54,6 +54,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (!name_len || name_len != size - value_len - 1) if (!name_len || name_len != size - value_len - 1)
return 0; return 0;
set_fontconfig_sysroot();
mpv_handle *ctx = mpv_create(); mpv_handle *ctx = mpv_create();
if (!ctx) if (!ctx)
exit(1); exit(1);