This is in preparation for GNU tar long file name support.
xt() should still behave exactly the same as it did before.
---
 tar.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/tar.c b/tar.c
index 77b94ff..fb7e7ab 100644
--- a/tar.c
+++ b/tar.c
@@ -457,16 +457,24 @@ xt(int argc, char *argv[], int mode)
                chktar(h);
                sanitize(h), n = 0;
 
+               if ((size = strtol(h->size, &p, 8)) < 0 || *p != '\0')
+                       eprintf("strtol %s: invalid number\n", h->size);
+
+               switch (h->type) {
+               /* ignore global pax header craziness */
+               case 'g':
+               case 'x':
+                       skipblk(size);
+                       continue;
+               }
+               
                /* small dance around non-null terminated fields */
                if (h->prefix[0])
                        n = snprintf(fname, sizeof(fname), "%.*s/",
                                     (int)sizeof(h->prefix), h->prefix);
                snprintf(fname + n, sizeof(fname) - n, "%.*s",
                         (int)sizeof(h->name), h->name);
-
-               if ((size = strtol(h->size, &p, 8)) < 0 || *p != '\0')
-                       eprintf("strtol %s: invalid number\n", h->size);
-
+               
                if (argc) {
                        /* only extract the given files */
                        for (i = 0; i < argc; i++)
@@ -478,17 +486,11 @@ xt(int argc, char *argv[], int mode)
                        }
                }
 
-               /* ignore global pax header craziness */
-               if (h->type == 'g' || h->type == 'x') {
-                       skipblk(size);
-                       continue;
-               }
-
                fn(fname, size, b);
                if (vflag && mode != 't')
                        puts(fname);
        }
-
+       
        if (mode == 'x' && !mflag) {
                while ((dirtime = popdirtime())) {
                        times[0].tv_sec = times[1].tv_sec = dirtime->mtime;
-- 
2.28.0


Reply via email to