tar/tar-fix-extract-unlink.patch
Marcus Meissner d8cbce283c Accepting request 1131478 from home:smolsheep:upgrades
- GNU tar 1.34:
  * Fail when building GNU tar if the platform supports 64-bit
    time_t but the build only uses 32-bit time_t.
  * Leave the devmajor and devminor fields empty (rather than
    zero) for non-special files, as this is more compatible with
    traditional tar.
  Fixes:
  * Fix interaction of --update with --wildcards.
  * When extracting archives into an empty directory, do not create
    hard links to files outside that directory.
  * Handle partial reads from regular files.
  * Warn file changed as we read it less often. Formerly, tar
    warned if the file's size or ctime changed. However, this
    generated a false positive if tar read a file while another
    process hard-linked to it, changing its ctime. Now, tar warns
    if the file's size, mtime, user ID, group ID, or mode changes.
    Although neither heuristic is perfect, the new one should work
    better in practice.
  * Fix --ignore-failed-read to ignore file-changed read errors
    as far as exit status is concerned. You can now suppress
    file-changed issues entirely with --ignore-failed-read
    --warning=no-file-changed.
  * Fix --remove-files to not remove a file that changed while we
    read it.
  * Fix --atime-preserve=replace to not fail if there was no need
    to replace, either because we did not read the file, or the
    atime did not change.
  * Fix race when creating a parent directory while another process
    is also doing so.
  * Fix handling of prefix keywords not followed by "." in pax
    headers.
  * Fix handling of out-of-range sparse entries in pax headers.
  * Fix handling of --transform='s/s/@/2'.
  * Fix treatment of options ending in slash in files-from list.
  * Fix crash on tar --checkpoint-action exec=\".
  * Fix low-memory crash when reading incremental dumps.
  * Fix --exclude-vcs-ignores memory allocation misuse.
- Update patch:
  * tar-backup-spec-fix-paths.patch: upstream fixed 2/3rd of paths
  * tar-fix-extract-unlink.patch
    some of this is overwritten by bsc1202436-1 and some was fixed
    upstream
  * add_readme-tests.patch as Makefile.in no longer exists
- Removed:
  * tar-fix-race-condition.patch
  * tar-avoid-overflow-in-symlinks-tests.patch
  * bsc1200657.patch
  * bsc1202436-2.patch
  * bsc1202436-1.patch

OBS-URL: https://build.opensuse.org/request/show/1131478
OBS-URL: https://build.opensuse.org/package/show/Base:System/tar?expand=0&rev=128
2023-12-07 15:47:00 +00:00

90 lines
2.7 KiB
Diff

diff --git a/src/extract.c b/src/extract.c
index 0261134f..f913575c 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -711,7 +711,7 @@ fixup_delayed_set_stat (char const *src, char const *dst)
directories were created, nonzero (issuing a diagnostic) otherwise.
Set *INTERDIR_MADE if at least one directory was created. */
static int
-make_directories (char *file_name)
+make_directories (char *file_name, bool *interdir_made)
{
char *cursor0 = file_name + FILE_SYSTEM_PREFIX_LEN (file_name);
char *cursor; /* points into the file name */
@@ -755,6 +755,7 @@ make_directories (char *file_name)
desired_mode, AT_SYMLINK_NOFOLLOW);
print_for_mkdir (file_name, desired_mode);
+ *interdir_made = true;
parent_end = NULL;
}
else
@@ -910,11 +911,8 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
case ENOENT:
/* Attempt creating missing intermediate directories. */
- if (make_directories (file_name) == 0)
- {
- *interdir_made = true;
+ if (make_directories (file_name, interdir_made) == 0)
return RECOVER_OK;
- }
break;
default:
@@ -1109,7 +1107,7 @@ extract_dir (char *file_name, int typeflag)
|| old_files_option == NO_OVERWRITE_DIR_OLD_FILES
|| old_files_option == DEFAULT_OLD_FILES
|| old_files_option == OVERWRITE_OLD_FILES)
- {
+ {
struct stat st;
st.st_mode = 0;
@@ -1117,21 +1115,21 @@ extract_dir (char *file_name, int typeflag)
&& is_directory_link (file_name, &st))
return 0;
- if ((st.st_mode != 0 && fstatat_flags == 0)
- || deref_stat (file_name, &st) == 0)
- {
+ if ((st.st_mode != 0 && fstatat_flags == 0)
+ || deref_stat (file_name, &st) == 0)
+ {
current_mode = st.st_mode;
current_mode_mask = ALL_MODE_BITS;
if (S_ISDIR (current_mode))
- {
- if (interdir_made)
- {
- repair_delayed_set_stat (file_name, &st);
- return 0;
- }
- else if (old_files_option == NO_OVERWRITE_DIR_OLD_FILES)
{
+ if (interdir_made)
+ {
+ repair_delayed_set_stat (file_name, &st);
+ return 0;
+ }
+ else if (old_files_option == NO_OVERWRITE_DIR_OLD_FILES)
+ {
/* Temporarily change the directory mode to a safe
value, to be able to create files in it, should
the need be.
@@ -2007,11 +2005,12 @@ rename_directory (char *src, char *dst)
else
{
int e = errno;
+ bool interdir_made;
switch (e)
{
case ENOENT:
- if (make_directories (dst) == 0)
+ if (make_directories (dst, &interdir_made) == 0)
{
if (renameat (chdir_fd, src, chdir_fd, dst) == 0)
return true;