summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-12-21 14:18:14 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-12-21 14:39:49 +0200
commit3c2a2cd94d3b062aa5bf850b82364039ec9c6029 (patch)
tree3bce2a1b74cf6d89772f612c37cc86f52a0d137d
parentea3aea06f1da077dbb4092672dc7e8768ae4f84e (diff)
downloadtar-3c2a2cd94d3b062aa5bf850b82364039ec9c6029.tar.gz
tar-3c2a2cd94d3b062aa5bf850b82364039ec9c6029.tar.bz2
Disallow modifications to the global pax extended header in update mode.
Updating global headers in update mode is not possible, because: 1) If the original archive was not in PAX format, writing the global header would overwrite first member header (and eventually data blocks) in the archive. 2) Otherwise, using the --pax-option can make the updated header occupy more blocks than the original one, which would lead to the same effect as in 1. This also fixes http://lists.gnu.org/archive/html/bug-tar/2018-12/msg00007.html * src/xheader.c (xheader_forbid_global): New function. * src/common.h (xheader_forbid_global): New prototype. * src/update.c (update_archive): Use xheader_forbid_global, instead of trying to write global extended header record.
-rw-r--r--src/common.h1
-rw-r--r--src/update.c2
-rw-r--r--src/xheader.c8
3 files changed, 10 insertions, 1 deletions
diff --git a/src/common.h b/src/common.h
index 32e6f8bd..885169fb 100644
--- a/src/common.h
+++ b/src/common.h
@@ -836,6 +836,7 @@ void xheader_store (char const *keyword, struct tar_stat_info *st,
void xheader_read (struct xheader *xhdr, union block *header, off_t size);
void xheader_write (char type, char *name, time_t t, struct xheader *xhdr);
void xheader_write_global (struct xheader *xhdr);
+void xheader_forbid_global (void);
void xheader_finish (struct xheader *hdr);
void xheader_destroy (struct xheader *hdr);
char *xheader_xhdr_name (struct tar_stat_info *st);
diff --git a/src/update.c b/src/update.c
index 2f823e45..4aa4ac6a 100644
--- a/src/update.c
+++ b/src/update.c
@@ -111,7 +111,7 @@ update_archive (void)
name_gather ();
open_archive (ACCESS_UPDATE);
- buffer_write_global_xheader ();
+ xheader_forbid_global ();
while (!found_end)
{
diff --git a/src/xheader.c b/src/xheader.c
index e9385022..010cab79 100644
--- a/src/xheader.c
+++ b/src/xheader.c
@@ -469,6 +469,14 @@ xheader_write_global (struct xheader *xhdr)
}
}
+/* Forbid modifications of the global extended header */
+void
+xheader_forbid_global (void)
+{
+ if (keyword_global_override_list)
+ USAGE_ERROR ((0, 0, _("can't update global extended header record")));
+}
+
void
xheader_xattr_init (struct tar_stat_info *st)
{

Return to:

Send suggestions and report system problems to the System administrator.