--- ./texk/web2c/texmfmp.h.orig 2021-06-25 11:32:31.312905780 +0000 +++ ./texk/web2c/texmfmp.h 2021-06-25 11:32:52.192921107 +0000 @@ -266,11 +266,28 @@ #define bopenout(f) open_output (&(f), FOPEN_WBIN_MODE) #define bclose aclose #ifdef FMT_COMPRESS + +#include +#include + +/* termux hack to disable file descriptor sanitizer */ +static int disable_fdsan() { + void *lib_handle = dlopen("libc.so", RTLD_LAZY); + if (lib_handle) { + void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level"); + if (set_fdsan_error_level) { + set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED); + } + dlclose(lib_handle); + } + return 1; +} + /* f is declared as gzFile, but we temporarily use it for a FILE * so that we can use the standard open calls */ -#define wopenin(f) (open_input ((FILE**)&(f), DUMP_FORMAT, FOPEN_RBIN_MODE) \ +#define wopenin(f) (disable_fdsan() && open_input ((FILE**)&(f), DUMP_FORMAT, FOPEN_RBIN_MODE) \ && (f = gzdopen(fileno((FILE*)f), FOPEN_RBIN_MODE))) -#define wopenout(f) (open_output ((FILE**)&(f), FOPEN_WBIN_MODE) \ +#define wopenout(f) (disable_fdsan() && open_output ((FILE**)&(f), FOPEN_WBIN_MODE) \ && (f = gzdopen(fileno((FILE*)f), FOPEN_WBIN_MODE)) \ && (gzsetparams(f, 1, Z_DEFAULT_STRATEGY) == Z_OK)) #define wclose(f) gzclose(f)