Date: Mon, 10 May 2004 22:07:16 +0200 (CEST) From: Christian Weisgerber <naddy@FreeBSD.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/66492: cpio -o -Hustar creates broken timestamps Message-ID: <200405102007.i4AK7GrL057642@kemoauc.mips.inka.de> Resent-Message-ID: <200405102010.i4AKAFtv017577@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 66492 >Category: bin >Synopsis: cpio -o -Hustar creates broken timestamps >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 10 13:10:14 PDT 2004 >Closed-Date: >Last-Modified: >Originator: Christian Weisgerber >Release: FreeBSD 5.2-CURRENT alpha >Organization: >Environment: System: FreeBSD kemoauc.mips.inka.de 5.2-CURRENT FreeBSD 5.2-CURRENT #1: Tue May 4 13:37:55 CEST 2004 naddy@kemoauc.mips.inka.de:/usr/obj/usr/src/sys/KEMOAUC alpha >Description: The cpio(1) command creates broken timestamps for ustar format archives. For additional details, see Debian bug report #238177: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=238177 >How-To-Repeat: $ touch foo $ echo foo | cpio -o -Hustar >foo.tar $ cpio -itv < foo.tar ... $ tar tvf foo.tar ... >Fix: >From David Kimdon <dwhedon@debian.org>: Index: tar.c =================================================================== RCS file: /home/ncvs/src/contrib/cpio/tar.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 tar.c --- tar.c 29 Mar 1997 22:40:44 -0000 1.1.1.1 +++ tar.c 10 May 2004 19:57:20 -0000 @@ -27,6 +27,7 @@ #include "tarhdr.h" static void to_oct (); +static void to_oct_no_nul (); static char *stash_tar_linkname (); static char *stash_tar_filename (); @@ -97,8 +98,8 @@ to_oct (file_hdr->c_mode, 8, tar_hdr->mode); to_oct (file_hdr->c_uid, 8, tar_hdr->uid); to_oct (file_hdr->c_gid, 8, tar_hdr->gid); - to_oct (file_hdr->c_filesize, 12, tar_hdr->size); - to_oct (file_hdr->c_mtime, 12, tar_hdr->mtime); + to_oct_no_nul (file_hdr->c_filesize, 12, tar_hdr->size); + to_oct_no_nul (file_hdr->c_mtime, 12, tar_hdr->mtime); switch (file_hdr->c_mode & CP_IFMT) { @@ -443,6 +444,21 @@ where[--digits] = ' '; } +/* Convert a number into a string of octal digits. + Convert long VALUE into a DIGITS-digit field at WHERE, + including a trailing space. DIGITS==2 means + 1 digit, and a space. +*/ + +static void +to_oct_no_nul (value, digits, where) + register long value; + register int digits; + register char *where; +{ + to_oct (value, digits + 1, where); +} + /* Return 2 if BUF is a valid POSIX tar header (the checksum is correct and it has the "ustar" magic string), >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405102007.i4AK7GrL057642>