This is just a quick hack for now, but we need something like it in
order to correctly extract some newer tars with correct timestamps, in
particular python-generated ones like
https://pypi.io/packages/source/w/wheel/wheel-0.36.2.tar.gz

Index: tar.c
===================================================================
RCS file: /cvs/src/bin/pax/tar.c,v
retrieving revision 1.69
diff -u -p -r1.69 tar.c
--- tar.c       14 Jun 2021 00:36:13 -0000      1.69
+++ tar.c       15 Oct 2021 21:40:49 -0000
@@ -784,12 +784,17 @@ reset:
        arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) &
            0xfff);
        arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
-       val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
-       if (val > MAX_TIME_T)
-               arcn->sb.st_mtime = INT_MAX;                    /* XXX 2038 */
-       else
-               arcn->sb.st_mtime = val;
-       arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
+       if (arcn->sb.st_mtime == 0) {
+               val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
+               if (val > MAX_TIME_T)
+                       arcn->sb.st_mtime = INT_MAX;            /* XXX 2038 */
+               else
+                       arcn->sb.st_mtime = val;
+       }
+       if (arcn->sb.st_ctime == 0)
+               arcn->sb.st_ctime = arcn->sb.st_mtime;
+       if (arcn->sb.st_atime == 0)
+               arcn->sb.st_atime = arcn->sb.st_mtime;
 
        /*
         * If we can find the ascii names for gname and uname in the password
@@ -1266,6 +1271,13 @@ rd_xheader(ARCHD *arcn, int global, off_
                        if (!strcmp(keyword, "path")) {
                                arcn->nlen = strlcpy(arcn->name, p,
                                    sizeof(arcn->name));
+                       } else if (!strcmp(keyword, "mtime")) {
+                               /* XXX error handling, and should parse 
nanoseconds */
+                               arcn->sb.st_mtime = strtoull(p, NULL, 10);
+                       } else if (!strcmp(keyword, "atime")) {
+                               arcn->sb.st_atime = strtoull(p, NULL, 10);
+                       } else if (!strcmp(keyword, "ctime")) {
+                               arcn->sb.st_ctime = strtoull(p, NULL, 10);
                        } else if (!strcmp(keyword, "linkpath")) {
                                arcn->ln_nlen = strlcpy(arcn->ln_name, p,
                                    sizeof(arcn->ln_name));

Reply via email to