]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Disallow modifications to the global pax extended header in update mode.
authorSergey Poznyakoff <gray@gnu.org>
Fri, 21 Dec 2018 12:18:14 +0000 (14:18 +0200)
committerSergey Poznyakoff <gray@gnu.org>
Fri, 21 Dec 2018 12:39:49 +0000 (14:39 +0200)
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.

src/common.h
src/update.c
src/xheader.c

index 32e6f8bd5f9158cfa2e437cf4bb5cc231b454758..885169fb82e67eb14db221c484bd5bda02d1f69e 100644 (file)
@@ -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);
index 2f823e45a02a29e5719a0a43dd1b6472217b34bb..4aa4ac6aa525328e0ed73a3aca20d6e8a7c8478d 100644 (file)
@@ -111,7 +111,7 @@ update_archive (void)
 
   name_gather ();
   open_archive (ACCESS_UPDATE);
-  buffer_write_global_xheader ();
+  xheader_forbid_global ();
 
   while (!found_end)
     {
index e93850220d7b340d37101f72c8ad535a36995766..010cab79044c065160dc8513a88e04e6c59712be 100644 (file)
@@ -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)
 {