termux-packages/packages/tar/mkfifoat.patch

31 lines
1.6 KiB
Diff

mkfifoat() is available in Android only after API 23. We can't use tar's
implementation of mkfifioat() since it will use tar's implementation of
mknodat(). This will cause infinite recursion in file gnu/at-func.c and
segfault.
Snippet of backtrace:
....
#9 0x000000555559819c in mknodat (fd=-100, file=0x7fb7c90050 "sda", mode=25008, dev=2048) at /home/builder/.termux-build/tar/src/gnu/at-func.c:75
#10 0x000000555559819c in mknodat (fd=-100, file=0x7fb7c90050 "sda", mode=25008, dev=2048) at /home/builder/.termux-build/tar/src/gnu/at-func.c:75
#11 0x000000555559819c in mknodat (fd=-100, file=0x7fb7c90050 "sda", mode=25008, dev=2048) at /home/builder/.termux-build/tar/src/gnu/at-func.c:75
#12 0x000000555559819c in mknodat (fd=-100, file=0x7fb7c90050 "sda", mode=25008, dev=2048) at /home/builder/.termux-build/tar/src/gnu/at-func.c:75
#13 0x000000555556a9d4 in extract_node (file_name=0x7fb7c90050 "sda", typeflag=52) at /home/builder/.termux-build/tar/src/src/extract.c:1447
#14 0x0000005555568f38 in extract_archive () at /home/builder/.termux-build/tar/src/src/extract.c:1709
....
diff -uNr tar-1.30/src/extract.c tar-1.30.mod/src/extract.c
--- tar-1.30/src/extract.c 2017-12-16 23:23:12.000000000 +0200
+++ tar-1.30.mod/src/extract.c 2017-12-25 14:31:31.541886176 +0200
@@ -42,6 +42,11 @@
# define fchown(fd, uid, gid) (errno = ENOSYS, -1)
#endif
+static int
+mkfifoat(int fd, const char* path, mode_t mode) {
+ return mknodat(fd, path, (mode & ~S_IFMT) | S_IFIFO, 0);
+}
+
/* Return true if an error number ERR means the system call is
supported in this case. */
static bool