From: Anssi Hannula Date: Wed, 6 Nov 2024 10:43:32 +0000 (+0200) Subject: Fix missing type in mknodat() mode argument X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=827dde1605a1acdaaee3afdcdde95dad0017f7eb;p=thirdparty%2Ftar.git Fix missing type in mknodat() mode argument Per POSIX, the type of the file to be created should be OR'ed to the `mode` argument of mknodat(). However, set_xattr() creates an empty file using mknodat() and does not do that. E.g. Linux kernel considers zero type as S_IFREG, so the code works on most systems. However, e.g. fakeroot, at least up to the current v1.36, does not consider 0 as S_IFREG, instead creating an invalid file, causing tar to enter an infinite retry loop when trying to create a file with xattrs under fakeroot. Since set_xattr is used only when extracting regular files, fix that by ORing its mode argument with S_IFREG. Copyright-paperwork-exempt: Yes --- diff --git a/src/extract.c b/src/extract.c index d810f10a..5d89458a 100644 --- a/src/extract.c +++ b/src/extract.c @@ -969,7 +969,7 @@ set_xattr (char const *file_name, struct tar_stat_info const *st, #ifdef HAVE_XATTRS if (xattrs_option && st->xattr_map.xm_size) { - int r = mknodat (chdir_fd, file_name, mode, 0); + int r = mknodat (chdir_fd, file_name, mode | S_IFREG, 0); if (r < 0) return r; xattrs_xattrs_set (st, file_name, typeflag, false);