slackbuilds/system/xar/patches/f_getpath_replacement.diff

31 lines
876 B
Diff

--- a/lib/archive.c 2024-09-24 16:39:21.000000000 -0400
+++ b/lib/archive.c 2024-11-23 21:12:31.213747869 -0500
@@ -493,6 +493,18 @@
return ret;
}
+/* 20241123 bkw: work around lack of fcntl() F_GETPATH on Linux */
+static int fd2path(int fd, char *buf) {
+ char procpath[PATH_MAX];
+
+ sprintf(procpath, "/proc/self/fd/%d", fd);
+
+ if(realpath(procpath, buf))
+ return 0;
+
+ return -1;
+}
+
xar_t xar_fdopen_digest_verify(int fd, int32_t flags, void *expected_toc_digest, size_t expected_toc_digest_len)
{
// Dup the descriptor vended to us so that we don't take ownership
@@ -507,7 +519,7 @@
// If there are hardlinks, the path we pick is the most recently opened by
// the filesystem; which is effectively random.
char path_buff[PATH_MAX];
- if (fcntl(fd, F_GETPATH, path_buff) < 0) {
+ if (fd2path(fd, path_buff) < 0) {
close(fd);
return NULL;
}