From owner-freebsd-bugs@FreeBSD.ORG Mon May 10 13:10:18 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B4D4416A4CF for ; Mon, 10 May 2004 13:10:18 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E02B643D53 for ; Mon, 10 May 2004 13:10:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i4AKAFo5017578 for ; Mon, 10 May 2004 13:10:15 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i4AKAFtv017577; Mon, 10 May 2004 13:10:15 -0700 (PDT) (envelope-from gnats) Resent-Date: Mon, 10 May 2004 13:10:15 -0700 (PDT) Resent-Message-Id: <200405102010.i4AKAFtv017577@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christian Weisgerber Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 241C016A4CE for ; Mon, 10 May 2004 13:07:21 -0700 (PDT) Received: from mail-in-03.arcor-online.net (mail-in-03.arcor-online.net [151.189.21.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B67E43D60 for ; Mon, 10 May 2004 13:07:19 -0700 (PDT) (envelope-from naddy@mips.inka.de) Received: from kemoauc.mips.inka.de (dsl-213-023-058-027.arcor-ip.net [213.23.58.27]) by mail-in-03.arcor-online.net (Postfix) with ESMTP id D8FC7C2EBF1 for ; Mon, 10 May 2004 22:07:17 +0200 (CEST) Received: from kemoauc.mips.inka.de (localhost [127.0.0.1]) i4AK7H4m057643 for ; Mon, 10 May 2004 22:07:17 +0200 (CEST) (envelope-from naddy@kemoauc.mips.inka.de) Received: (from naddy@localhost) by kemoauc.mips.inka.de (8.12.11/8.12.11/Submit) id i4AK7GrL057642; Mon, 10 May 2004 22:07:16 +0200 (CEST) (envelope-from naddy) Message-Id: <200405102007.i4AK7GrL057642@kemoauc.mips.inka.de> Date: Mon, 10 May 2004 22:07:16 +0200 (CEST) From: Christian Weisgerber To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/66492: cpio -o -Hustar creates broken timestamps X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Christian Weisgerber List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 May 2004 20:10:18 -0000 >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 : 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: