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
This commit is contained in:
committed by
Sergey Poznyakoff
parent
65228e9ba9
commit
827dde1605
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user