|
|
2b8e17 |
From 910d9ff829bbdfaf1455cdb2b1813507bcb855ec Mon Sep 17 00:00:00 2001
|
|
|
2b8e17 |
From: Ondrej Dubaj <odubaj@redhat.com>
|
|
|
2b8e17 |
Date: Tue, 13 Apr 2021 11:47:32 +0200
|
|
|
2b8e17 |
Subject: [PATCH] add padding message, when read error occurs and tar is
|
|
|
2b8e17 |
padding with zeros
|
|
|
2b8e17 |
|
|
|
2b8e17 |
---
|
|
|
2b8e17 |
lib/paxerror.c | 44 ++++++++++++++++++++++++++++++--------------
|
|
|
2b8e17 |
lib/paxlib.h | 4 ++--
|
|
|
2b8e17 |
src/common.h | 2 +-
|
|
|
2b8e17 |
src/create.c | 2 +-
|
|
|
2b8e17 |
src/misc.c | 6 +++---
|
|
|
2b8e17 |
src/sparse.c | 6 +++---
|
|
|
2b8e17 |
6 files changed, 40 insertions(+), 24 deletions(-)
|
|
|
2b8e17 |
|
|
|
2b8e17 |
diff --git a/lib/paxerror.c b/lib/paxerror.c
|
|
|
2b8e17 |
index 134cef3..929a741 100644
|
|
|
2b8e17 |
--- a/lib/paxerror.c
|
|
|
2b8e17 |
+++ b/lib/paxerror.c
|
|
|
2b8e17 |
@@ -173,29 +173,45 @@ read_error (char const *name)
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void
|
|
|
2b8e17 |
-read_error_details (char const *name, off_t offset, size_t size)
|
|
|
2b8e17 |
+read_error_details (char const *name, off_t offset, size_t size, bool padding)
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
char buf[UINTMAX_STRSIZE_BOUND];
|
|
|
2b8e17 |
int e = errno;
|
|
|
2b8e17 |
- ERROR ((0, e,
|
|
|
2b8e17 |
- ngettext ("%s: Read error at byte %s, while reading %lu byte",
|
|
|
2b8e17 |
- "%s: Read error at byte %s, while reading %lu bytes",
|
|
|
2b8e17 |
- size),
|
|
|
2b8e17 |
- quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
- (unsigned long) size));
|
|
|
2b8e17 |
+ if (padding)
|
|
|
2b8e17 |
+ ERROR ((0, e,
|
|
|
2b8e17 |
+ ngettext ("%s: Read error at byte %s, while reading %lu byte; padding with zeros",
|
|
|
2b8e17 |
+ "%s: Read error at byte %s, while reading %lu bytes; padding with zeros",
|
|
|
2b8e17 |
+ size),
|
|
|
2b8e17 |
+ quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
+ (unsigned long) size));
|
|
|
2b8e17 |
+ else
|
|
|
2b8e17 |
+ ERROR ((0, e,
|
|
|
2b8e17 |
+ ngettext ("%s: Read error at byte %s, while reading %lu byte",
|
|
|
2b8e17 |
+ "%s: Read error at byte %s, while reading %lu bytes",
|
|
|
2b8e17 |
+ size),
|
|
|
2b8e17 |
+ quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
+ (unsigned long) size));
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void
|
|
|
2b8e17 |
-read_warn_details (char const *name, off_t offset, size_t size)
|
|
|
2b8e17 |
+read_warn_details (char const *name, off_t offset, size_t size, bool padding)
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
char buf[UINTMAX_STRSIZE_BOUND];
|
|
|
2b8e17 |
int e = errno;
|
|
|
2b8e17 |
- WARN ((0, e,
|
|
|
2b8e17 |
- ngettext ("%s: Warning: Read error at byte %s, while reading %lu byte",
|
|
|
2b8e17 |
- "%s: Warning: Read error at byte %s, while reading %lu bytes",
|
|
|
2b8e17 |
- size),
|
|
|
2b8e17 |
- quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
- (unsigned long) size));
|
|
|
2b8e17 |
+ if (padding)
|
|
|
2b8e17 |
+ WARN ((0, e,
|
|
|
2b8e17 |
+ ngettext ("%s: Warning: Read error at byte %s, while reading %lu byte; padding with zeros",
|
|
|
2b8e17 |
+ "%s: Warning: Read error at byte %s, while reading %lu bytes; padding with zeros",
|
|
|
2b8e17 |
+ size),
|
|
|
2b8e17 |
+ quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
+ (unsigned long) size));
|
|
|
2b8e17 |
+ else
|
|
|
2b8e17 |
+ WARN ((0, e,
|
|
|
2b8e17 |
+ ngettext ("%s: Warning: Read error at byte %s, while reading %lu byte",
|
|
|
2b8e17 |
+ "%s: Warning: Read error at byte %s, while reading %lu bytes",
|
|
|
2b8e17 |
+ size),
|
|
|
2b8e17 |
+ quotearg_colon (name), STRINGIFY_BIGINT (offset, buf),
|
|
|
2b8e17 |
+ (unsigned long) size));
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void
|
|
|
2b8e17 |
diff --git a/lib/paxlib.h b/lib/paxlib.h
|
|
|
2b8e17 |
index d4251d1..ccf826b 100644
|
|
|
2b8e17 |
--- a/lib/paxlib.h
|
|
|
2b8e17 |
+++ b/lib/paxlib.h
|
|
|
2b8e17 |
@@ -94,10 +94,10 @@ void open_error (char const *);
|
|
|
2b8e17 |
void open_fatal (char const *) __attribute__ ((noreturn));
|
|
|
2b8e17 |
void open_warn (char const *);
|
|
|
2b8e17 |
void read_error (char const *);
|
|
|
2b8e17 |
-void read_error_details (char const *, off_t, size_t);
|
|
|
2b8e17 |
+void read_error_details (char const *, off_t, size_t, bool);
|
|
|
2b8e17 |
void read_fatal (char const *) __attribute__ ((noreturn));
|
|
|
2b8e17 |
void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn));
|
|
|
2b8e17 |
-void read_warn_details (char const *, off_t, size_t);
|
|
|
2b8e17 |
+void read_warn_details (char const *, off_t, size_t, bool);
|
|
|
2b8e17 |
void readlink_error (char const *);
|
|
|
2b8e17 |
void readlink_warn (char const *);
|
|
|
2b8e17 |
void rmdir_error (char const *);
|
|
|
2b8e17 |
diff --git a/src/common.h b/src/common.h
|
|
|
2b8e17 |
index bbe167e..34a30ec 100644
|
|
|
2b8e17 |
--- a/src/common.h
|
|
|
2b8e17 |
+++ b/src/common.h
|
|
|
2b8e17 |
@@ -713,7 +713,7 @@ int chdir_count (void);
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void close_diag (char const *name);
|
|
|
2b8e17 |
void open_diag (char const *name);
|
|
|
2b8e17 |
-void read_diag_details (char const *name, off_t offset, size_t size);
|
|
|
2b8e17 |
+void read_diag_details (char const *name, off_t offset, size_t size, bool padding);
|
|
|
2b8e17 |
void readlink_diag (char const *name);
|
|
|
2b8e17 |
void savedir_diag (char const *name);
|
|
|
2b8e17 |
void seek_diag_details (char const *name, off_t offset);
|
|
|
2b8e17 |
diff --git a/src/create.c b/src/create.c
|
|
|
2b8e17 |
index 712ee18..181f7d9 100644
|
|
|
2b8e17 |
--- a/src/create.c
|
|
|
2b8e17 |
+++ b/src/create.c
|
|
|
2b8e17 |
@@ -1090,7 +1090,7 @@ dump_regular_file (int fd, struct tar_stat_info *st)
|
|
|
2b8e17 |
if (count == SAFE_READ_ERROR)
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
read_diag_details (st->orig_file_name,
|
|
|
2b8e17 |
- st->stat.st_size - size_left, bufsize);
|
|
|
2b8e17 |
+ st->stat.st_size - size_left, bufsize, true);
|
|
|
2b8e17 |
pad_archive (size_left);
|
|
|
2b8e17 |
return dump_status_short;
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
diff --git a/src/misc.c b/src/misc.c
|
|
|
2b8e17 |
index eccf6f9..28c6f44 100644
|
|
|
2b8e17 |
--- a/src/misc.c
|
|
|
2b8e17 |
+++ b/src/misc.c
|
|
|
2b8e17 |
@@ -1069,15 +1069,15 @@ open_diag (char const *name)
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void
|
|
|
2b8e17 |
-read_diag_details (char const *name, off_t offset, size_t size)
|
|
|
2b8e17 |
+read_diag_details (char const *name, off_t offset, size_t size, bool padding)
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
if (ignore_failed_read_option)
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
if (WARNING_ENABLED(WARN_FAILED_READ))
|
|
|
2b8e17 |
- read_warn_details (name, offset, size);
|
|
|
2b8e17 |
+ read_warn_details (name, offset, size, padding);
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
else
|
|
|
2b8e17 |
- read_error_details (name, offset, size);
|
|
|
2b8e17 |
+ read_error_details (name, offset, size, padding);
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
|
|
|
2b8e17 |
void
|
|
|
2b8e17 |
diff -rup tar-1.34/src/sparse.c.old tar-1.34/src/sparse.c
|
|
|
2b8e17 |
--- tar-1.34/src/sparse.c.old 2022-06-27 09:15:48.580574517 +0000
|
|
|
2b8e17 |
+++ tar-1.34/src/sparse.c 2022-06-27 09:18:28.500574517 +0000
|
|
|
2b8e17 |
@@ -424,7 +424,7 @@ sparse_dump_region (struct tar_sparse_fi
|
|
|
2b8e17 |
(file->stat_info->sparse_map[i].offset
|
|
|
2b8e17 |
+ file->stat_info->sparse_map[i].numbytes
|
|
|
2b8e17 |
- bytes_left),
|
|
|
2b8e17 |
- bufsize);
|
|
|
2b8e17 |
+ bufsize, false);
|
|
|
2b8e17 |
return false;
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
else if (bytes_read == 0)
|
|
|
2b8e17 |
@@ -619,7 +619,7 @@ check_sparse_region (struct tar_sparse_f
|
|
|
2b8e17 |
{
|
|
|
2b8e17 |
read_diag_details (file->stat_info->orig_file_name,
|
|
|
2b8e17 |
beg,
|
|
|
2b8e17 |
- rdsize);
|
|
|
2b8e17 |
+ rdsize, false);
|
|
|
2b8e17 |
return false;
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
else if (bytes_read == 0)
|
|
|
2b8e17 |
@@ -674,7 +674,7 @@ check_data_region (struct tar_sparse_fil
|
|
|
2b8e17 |
(file->stat_info->sparse_map[i].offset
|
|
|
2b8e17 |
+ file->stat_info->sparse_map[i].numbytes
|
|
|
2b8e17 |
- size_left),
|
|
|
2b8e17 |
- rdsize);
|
|
|
2b8e17 |
+ rdsize, false);
|
|
|
2b8e17 |
return false;
|
|
|
2b8e17 |
}
|
|
|
2b8e17 |
else if (bytes_read == 0)
|