X-Git-Url: https://git.distorted.org.uk/~mdw/termux-packages/blobdiff_plain/59c1f3a1389f522c79fe9b2999b431c4daac349c..dc6476e9eadbdd6476a870cacc4ce63dba99c51c:/ndk_patches/stdio.h.patch diff --git a/ndk_patches/stdio.h.patch b/ndk_patches/stdio.h.patch index 630c4c90..c64fda15 100644 --- a/ndk_patches/stdio.h.patch +++ b/ndk_patches/stdio.h.patch @@ -1,8 +1,19 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h ./usr/include/stdio.h ---- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h 2014-10-14 22:53:49.000000000 -0400 -+++ ./usr/include/stdio.h 2014-12-14 15:11:46.007242332 -0500 -@@ -193,7 +193,7 @@ - +--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/stdio.h 2016-03-03 16:54:24.000000000 -0500 ++++ ./usr/include/stdio.h 2016-04-11 06:54:22.893930847 -0400 +@@ -52,6 +52,10 @@ + #include + #include + ++#include /* For strcpy(3) used by ctermid() */ ++#include /* For O_RDWR and other O_* constants */ ++#include /* For arc4random() */ ++ + #define __need_NULL + #include + +@@ -193,7 +196,7 @@ + /* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ #if __BSD_VISIBLE || __XPG_VISIBLE -#define P_tmpdir "/tmp/" @@ -10,10 +21,18 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/incl #endif #define L_tmpnam 1024 /* XXX must be == PATH_MAX */ #define TMP_MAX 308915776 -@@ -371,6 +371,16 @@ +@@ -257,7 +260,6 @@ + int setvbuf(FILE * __restrict, char * __restrict, int, size_t); + int sscanf(const char * __restrict, const char * __restrict, ...) + __scanflike(2, 3); +-FILE *tmpfile(void); + int ungetc(int, FILE *); + int vfprintf(FILE * __restrict, const char * __restrict, __va_list) + __printflike(2, 0); +@@ -371,6 +373,16 @@ #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) #endif /* __BSD_VISIBLE */ - + +/* Needed by gnulibs freading() */ +#define __sferror(p) (((p)->_flags & __SERR) != 0) + @@ -25,5 +44,35 @@ diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/incl +} + #if defined(__BIONIC_FORTIFY) - + __BEGIN_DECLS +@@ -462,4 +474,29 @@ + + #endif /* defined(__BIONIC_FORTIFY) */ + ++__BEGIN_DECLS ++ ++extern int open(const char*, int, ...); ++extern pid_t getpid(); ++extern int unlink(const char*); ++static FILE* tmpfile() { ++ int p = getpid(); ++ char* path; ++ int i; ++ for (i = 0; i < 100; i++) { ++ unsigned int r = arc4random(); ++ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL; ++ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE); ++ free(path); ++ if (fd >= 0) { ++ FILE* result = fdopen(fd, "w+"); ++ unlink(path); ++ return result; ++ } ++ } ++ return NULL; ++} ++ ++__END_DECLS ++ + #endif /* _STDIO_H_ */