On Mon, Jun 26, 2023 at 11:09:10AM -0600, Todd C. Miller wrote:

> If the mtime in the file header is larger than MAX_TIME_T, trucate
> it to MAX_TIME_T, not INT_MAX.  The existing assignment dates from
> before we had a MAX_TIME_T definition in pax.

How strange the checks use MAX_TIME_T as a bound value, but the
assignments not.  For FFS1 it likely does not matter, since its
timestamps are 32-bit on disk.  But for ffs2 it does.

OK,

        -Otto


> 
> OK?
> 
>  - todd
> 
> Index: cpio.c
> ===================================================================
> RCS file: /cvs/src/bin/pax/cpio.c,v
> retrieving revision 1.33
> diff -u -p -u -r1.33 cpio.c
> --- cpio.c    16 Sep 2017 07:42:34 -0000      1.33
> +++ cpio.c    26 Jun 2023 17:05:35 -0000
> @@ -294,7 +294,7 @@ cpio_rd(ARCHD *arcn, char *buf)
>       arcn->sb.st_rdev = (dev_t)asc_ul(hd->c_rdev, sizeof(hd->c_rdev), OCT);
>       val = asc_ull(hd->c_mtime, sizeof(hd->c_mtime), OCT);
>       if (val > MAX_TIME_T)
> -             arcn->sb.st_mtime = INT_MAX;                    /* XXX 2038 */
> +             arcn->sb.st_mtime = MAX_TIME_T;
>       else
>               arcn->sb.st_mtime = val;
>       arcn->sb.st_mtim.tv_nsec = 0;
> Index: tar.c
> ===================================================================
> RCS file: /cvs/src/bin/pax/tar.c,v
> retrieving revision 1.70
> diff -u -p -u -r1.70 tar.c
> --- tar.c     1 Mar 2022 21:19:11 -0000       1.70
> +++ tar.c     26 Jun 2023 17:05:35 -0000
> @@ -411,7 +411,7 @@ tar_rd(ARCHD *arcn, char *buf)
>       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 */
> +             arcn->sb.st_mtime = MAX_TIME_T;
>       else
>               arcn->sb.st_mtime = val;
>       arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
> @@ -788,7 +788,7 @@ reset:
>       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 */
> +                     arcn->sb.st_mtime = MAX_TIME_T;
>               else
>                       arcn->sb.st_mtime = val;
>       }
> 

Reply via email to